home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / expressionEditor.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  80.4 KB  |  2,978 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  ==================== expressionEditor.mel ==========
  22. //
  23. //  SYNOPSIS
  24. //      Create and show a text dialog for creating and editing
  25. //        expressions
  26. //
  27. //  CONTENTS
  28. //        
  29. //  PROCEDURES TO CREATE THE EXPRESSION EDITOR UI AND TOGGLE BETWEEN LAYOUTS.  
  30. //        These are in expressionEditor.mel
  31. //
  32. //    EEmakeMenubar            Make the menubar menus.
  33. //    EEmakeFilterPopup        Make filter popup menu.
  34. //    EEcreateWin()            Create the expression editor window
  35. //  EEpostConfirm            Post a confirm dialog.
  36. //    EEswitchSelectLayout    Switch between select-by-expr/obj modes.
  37. //  EEswitchRulesForm       Make visible/invisible rules form
  38. //
  39. //
  40. //   EXPRESSION EDITOR QUERY PROCEDURES
  41. //        These are in expressionEditor.mel
  42. //
  43. //  EEgetCurrTypeList       Get/return list of all objects of specified type.
  44. //  EEgetExpressionList        Get/return list of all expressions in the scene.
  45. //    EEgetAttrFromNode        Get the attribute from the node, if it's there.
  46. //  EEgetEditorMessage        Return a message re WINEDITOR.
  47. //    EEisValidNodeName        Is user-typed node name valid?
  48. //    EEexprNameExists        Does user-typed expression node name exist?
  49. //    EEcheckValidExprName    Is user-typed expression node name valid?
  50. //    EEnodeIsInList            Is the node in the current node list?
  51. //    EEattrIsInList            Is the attribute in the current attribute list?
  52. //
  53. //    EXPRESSION EDITOR UI EDIT AND LIST MANAGEMENT PROCEDURES:
  54. //        These are in expressionEditor.mel
  55. //
  56. //    EEsetCreateMode            Set the editor to create mode.
  57. //  EEsetEditMode            Set the editor to edit mode.
  58. //    EEclearAllControls        Clear name textfields and menus.
  59. //    EEresetFilterToAll        Set object filter to dag or dependency nodes.
  60. //    EEresetExpressionName    Reset the expression name textfield
  61. //    EEresetNodeControls        Reset controls for a new selected node.
  62. //    EErebuildNodeList        Rebuild the node selection list.
  63. //    EErebuildAttrList         Rebuild the attribute list.
  64. //    EEupdateExprList        Update the list of expressions.
  65. //  EEaddNodeToList            Add a node to the node list.
  66. //  EEremoveNodeFromList    Remove a node from the node list.
  67. //  EEselectNodeInList        Select a node in the node list.
  68. //    EEnewSelectedNode        Make the node selected and load its attrlist.
  69. //    EEnewSelectedAttr        Load a new attribute into the editor.
  70. //    EEloadNewNodeAttr        Load a new new node and its expression.
  71. //    EEdisplayAttrExpr        Display the expression of the current attribute.
  72. //    EEdisplayNoExpression    Reset controls when attr has no expression.
  73. //
  74. //    EEregisterExpressions    Register expressions to get expr changed msgs.
  75. //
  76. //
  77. //    CORE PROCEDURES
  78. //        These are in expressionEditor.mel
  79. //
  80. //    EEupdateWindow            Update the window at creation/show time.
  81. //  expressionEditor()        Create or display the expression editor  (main)
  82. //
  83. //  PROCEDURES TO HANDLE ONLY REGULAR EXPRESSIONS
  84. //        These are all in expressions.mel
  85. //
  86. //    EEexpressionCmd            Print the expression command just issued.
  87. //    EEapplyExpression        Create or edit the expression
  88. //    EErestoreExpression        Restore the current expression from the node.
  89. //  EEobjectListChanged        User selected a non-particle obj in the node list.
  90. //  EEexpressionListChanged    User selected a new expression in the node list.
  91. //    EEdisplayExpression        Display an expression.
  92. //
  93. // PROCEDURES TO HANDLE ONLY PARTICLE EXPRESSION
  94. //        These are all in dynExpressions.mel
  95. //
  96. //    EEdynExpressionCmd        Print the expression command just issued.
  97. //    EEapplyParticleExpression    Create or edit the particle expression
  98. //    EErestoreParticleExpression    Restore curr particle expression from node.
  99. //  EEparticleListChanged    User selected a particle in the node list.
  100. //    EEdisplayParticleExpression    Display a particle expression.
  101. //    EEisParticle            Is the node a particle?
  102. //    EEisDynExpression        Is the particle expression a dynExpression?
  103. //    EEisValidDynAttr        Is the particle attribute a valid one to show?
  104. //    EEgetParticleExpression Get the p. expression from the particle
  105. //    EEonlyLaunchParticleEditor Launch a text editor for a particle expression.
  106. //
  107. //  EXPRESSION EDITOR UI CONTROL CALLBACKS:
  108. //        These are all in expressionEdCallbacks.mel
  109. //
  110. //    EEapplyCB                Create/Edit the expression.
  111. //    EEdeleteCB                Delete the expression.
  112. //    EErestoreCB                Restore the expression.
  113. //    EEclearCB                Clear the text area.
  114. //  EEcloseCB                Close the window.
  115. //    EEanimatedCB            Callback for animated checkbox.
  116. //    EEunitConversionCB        Callback for unit conversion radio group.
  117. //    EEexprNameTextCB        Callback for expression name textfield.
  118. //    EEdefaultNodeCB            Callback for default node name textfield.
  119. //    EEselectedNodeAttrCB    Callback for node-attribute name textfield.
  120. //    EEnewExpressionCB        Callback for "New Expression" Button.
  121. //    EEnodeListCB            User selected something (sngl click) in node list.
  122. //    EEnodeListDblClickCB    User selected something (dbl click) in node list
  123. //    EEattrListCB            User selected something (sngl click)in attr list.
  124. //    EEattrListDblClickCB    User selected something (dbl click) in attr list.
  125. //    EEselectFilterCB        User selected something in the Select menu.
  126. //    EEobjFilterCB            User selected something in the Obj Filter menu.
  127. //    EEattrFilterCB            User selected something in the Attr Filter menu.
  128. //  EEeditorCB                User selected something in editors opt menu.
  129. //    EErulesCB                User selected a rules radio button.
  130. //
  131. //    EXPRESSION EDITOR MESSAGE CALLBACKS
  132. //        These are in expressionEdCallbacks.mel
  133. //        These are called from TexprEdListenAction.cc
  134. //
  135. //  EEactiveListChanged       Callback for active list changed.
  136. //  EEnodeAdded             Callback for a node added to a scene.
  137. //  EEnodeRemoved             Callback for a node removed from the scene.
  138. //    EEparticleExpressionCreated    Callback for particle expression created.
  139. //    EEparticleExpressionDeleted    Callback for particle expression deleted.
  140. //    EEexpressionCreated        Callback for expression created.
  141. //    EEexpressionEdited        Callback for expression edited.
  142. //    EEparticleExpressionEdited    Callback for particle expression edited.
  143. //  EEnodeNameChanged         Callback for a node name change in the scene.
  144. //  EEattributeAdded          Callback for attribute added to selected node.
  145. //  EEattributeRemoved        Callback for attribute removed from selected node.
  146. //
  147. //  EXPRESSION EDITOR TEXT EDITOR AND FAM HANDLING ROUTINES
  148. //        These are in expressionEdTextEditor.mel
  149. //
  150. //    EEdoLaunch                Do the launch of the user's text editor of choice.
  151. //    EElaunchEditor            Launch a text editor for a regular expression.
  152. //    EElaunchParticleEditor    Launch a text editor for a particle expression
  153. //    EEgetFileExpression        Callback from TexprEdFamAction.cc when the user
  154. //                            writes text editor file to disk.  Read file.
  155. //  EEupdateParticleFileExpression  Update a particle expression from a text editor file.
  156. //  EEupdateFileExpression  Update a regular expression from a text editor file.
  157. //  EEdeleteStringElement    Delete an element from a string array.
  158. //  EEdeleteIntElement        Delete an element from an int array.
  159. //  EEdeleteEditorFile        Callback from TexprEdFamAction.cc when user
  160. //                             dismisses a text editor.  Delete the file.
  161. //
  162.  
  163. // ******************************************************************
  164. //
  165. //                    EXPRESSION EDITOR GLOBAL VARIABLES
  166. //
  167. // ******************************************************************
  168. // 
  169. global int $EEcreateMode = 1;   // 1 = creating; 0 = editing
  170.  
  171. // Some of these globals are needed, because if in text editor mode,
  172. // the controls cannot be queried, since the Expression Editor window
  173. // won't be created when calling up the Expression Editor from the
  174. // Attribute Editor or Channel Editor.
  175. //
  176. global int $EEobjIsParticle = 0;
  177. global int $EEisRuntime = 1;
  178. global int $EEcurrentEditor = 1;
  179. global int $EEdoLaunchTextEd = 0;
  180. global string $EEcurrExpressionName;
  181. global string $EEorigExpressionName;
  182. global int $EEeditedInEditor = 0;
  183.  
  184. global string $EEcurrSelectedNode;
  185.  
  186. // Currently active menu/filter modes.
  187. //
  188. global string $EEnodeMode = "object";
  189. global string $EEcurrNodeFilter = "allSelected";
  190. global string $EEcurrAttrFilter = "all";
  191.  
  192. // List of all files in text editors that are editing a particle expression.
  193. //
  194. global string $EEcurrParticleFiles[];
  195.  
  196. // Index into EEcurrFiles and EEcurrParticleFiles of the file whose
  197. // expression is currently being displayed in the expression editor.
  198. //
  199. global int      $EEpExpressionInEditor = -1;
  200. global int      $EEexpressionInEditor = -1;
  201.  
  202. global int    $EEfilesLoaded = 0;
  203.  
  204. global int    $EEfilesLoaded = 0;
  205.  
  206. // begin} Math Functions ----  Count 28
  207. global string $EEMathFunction[] = { 
  208.         "abs()",     "float abs(float) / int abs(int) / vector abs(vector)",
  209.         "acos()",     "float acos(float number)",
  210.         "acosd()",     "float acosd(float number)",
  211.         "asin()",     "float asin(float number)",
  212.         "asind()",     "float asind(float number)",
  213.         "atan()",     "float atan(float number)",
  214.         "atand()",     "float atand(float number)",
  215.         "atan2()",     "float atan2(float Y, float X)",
  216.         "atan2d()",    "float atan2d(float Y, float X)",
  217.         "clamp()",     "float clamp(float min, float max, float parameter)",
  218.         "ceil()",     "float ceil(float number)",
  219.         "cos()",     "float cos(float number)",
  220.         "cosd()",     "float cosd(float number)",
  221.         "exp()",     "float exp(float number)",
  222.         "floor()",     "float floor(float number)",
  223.         "hypot()",     "float hypot(float x, float y)",
  224.         "log()",     "float log(float number)",
  225.         "log10()",     "float log10(float number)",
  226.         "min()",     "float min(float number, float number)",
  227.         "max()",     "float max(float number, float number)",
  228.         "pow()",     "float pow(float base, float exponent)",
  229.         "sign()",     "float sign(float number)",
  230.         "sin()",     "float sin(float number)",
  231.         "sind()",     "float sind(float number)",
  232.         "sqrt()",     "float sqrt(float number)",
  233.         "tan()",     "float tan(float number)",
  234.         "tand()",     "float tand(float number)",
  235.         "trunc()",    "float trunc(float number)"
  236.                                     };
  237. // end} Math Functions ----
  238.  
  239. // begin} Vector Functions ----  Count 6
  240. global string $EEVectorFunction[] = { 
  241.         "angle()",    "float angle(vector vector1, vector vector2)",
  242.         "cross()",     "vector cross(vector vector1, vector vector2)",
  243.         "dot()",     "float dot(vector vector1, vector vector2)",
  244.         "mag()",     "float mag(vector)",
  245.         "rot()",     "vector rot(vector point, vector axis, float angle)",
  246.         "unit()",    "vector unit(vector)"
  247.                                     };
  248. // end} Vector Functions ----
  249.  
  250. // begin} Conversion Functions ----  Count 4
  251. global string $EEConversionFunction[] = { 
  252.         "deg_to_rad()", "float deg_to_rad(float degrees)",
  253.         "rad_to_deg()", "float rad_to_deg(float radians)",
  254.         "hsv_to_rgb()", "vector hsv_to_rgb(vector hsv)",
  255.         "rgb_to_hsv()", "vector rgb_to_hsv(vector rgb)"
  256.                                     };
  257. // end} Conversion Functions ----
  258.  
  259. // begin} Random Number Functions ----  Count 6
  260. global string $EERandomFunction[] = { 
  261.         "gauss()",         "float gauss(float) / vector gauss(float, float) / vector gauss(vector)",
  262.         "noise()",         "float noise(float) / float noise(float, float) / float noise(vector)",
  263.         "dnoise()",     "vector dnoise(vector)",
  264.         "rand()",         "float rand(float [,float]) / vector rand(vector [,vector])",
  265.         "sphrand()",     "vector sphrand(float) / vector sphrand(vector)",
  266.         "seed()",         "int seed(int)"
  267.                                     };
  268. // end} Random Number Functions ----
  269.  
  270. // begin}  Array Functions ----  Count 3
  271. global string $EEArrayFunction[] = { 
  272.         "clear()",     "int clear(array)",
  273.         "size()",     "int size(array) / int size(string)",
  274.         "sort()",     "array sort(array)"
  275.                                     };
  276. // end} Array Functions ----
  277.  
  278. // begin}  Curve Functions ----  Count 3
  279. // This block has distinct elements for the menu label
  280. // (the first string in each set)
  281. // and the literal string to insert in the expression (the second)
  282. // in order to distinguish between the 2 overloaded versions of hermite().
  283. global string $EECurveFunction[] = { 
  284.         "linstep()", "linstep()", "float linstep(float start, float end, float parameter)",
  285.         "smoothstep()", "smoothstep()", "float smoothstep(float start, float end, float parameter)", 
  286.         "hermite() (vector)", "hermite()", "vector hermite(vector start, vector end, vector tan1, vector tan2, float parameter)",
  287.         "hermite() (scalar)", "hermite()", "float hermite(float start, float end, float tan1, float tan2, float parameter)"
  288.                                     };
  289. // end} Curve Functions ----
  290.  
  291.  
  292.  
  293. // ******************************************************************
  294. //
  295. //                EXPRESSION EDITOR UI CREATION PROCEDURES
  296. //
  297. // ******************************************************************
  298.  
  299. //  ================ EEmakeMenubar ================
  300. //
  301. //  SYNOPSIS
  302. //        Make the menus for the expression editor.
  303. //
  304. global proc EEmakeMenubar()
  305. {
  306.     global string $EEnodeMode;
  307.     global string $EEcurrNodeFilter;
  308.     global string $EEcurrAttrFilter;
  309.  
  310.     menu -l "Select Filter"
  311.         -familyImage "menuIconSelectFilter.xpm";
  312.         radioMenuItemCollection;
  313.         menuItem -l "By Expression Name" 
  314.             -rb ($EEnodeMode == "expression")
  315.             -c ("EEselectFilterCB expression")
  316.             EEexprModeMenuItem;
  317.         menuItem -l "By Object/Attribute Name" 
  318.             -rb ($EEnodeMode == "object")
  319.             -c ("EEselectFilterCB object") 
  320.             EEobjModeMenuItem;
  321.         menuItem -l "By Script Node Name"
  322.             -rb ($EEnodeMode == "scriptNode")
  323.             -c ("EEselectFilterCB scriptNode")
  324.             EEscriptNodeModeMenuItem;
  325.         setParent -m ..;
  326.         
  327.     menu -l "Object Filter" 
  328.         -familyImage "menuIconObjectFilter.xpm"
  329.         EEobjFilterMenu;
  330.         radioMenuItemCollection;
  331.             menuItem -l "Selected Objects" 
  332.                 -rb ($EEcurrNodeFilter == "allSelected")  
  333.                 -c ("EEobjFilterCB allSelected")
  334.                 EEallSelectedMenuItem;
  335.             menuItem -l "Dag Objects" 
  336.                 -rb ($EEcurrNodeFilter == "dagObjects")  
  337.                 -c ("EEobjFilterCB dagObjects")
  338.                 EEdagObjMenuItem;
  339.             menuItem -l "Geometry Objects" 
  340.                 -rb ($EEcurrNodeFilter == "geometry") 
  341.                 -c ("EEobjFilterCB geometry");
  342.             menuItem -l "Transforms" 
  343.                 -rb ($EEcurrNodeFilter == "transforms")  
  344.                 -c ("EEobjFilterCB transforms");
  345.             menuItem -l "Dependency Nodes" 
  346.                 -rb ($EEcurrNodeFilter == "depNodes") 
  347.                 -c ("EEobjFilterCB depNodes")
  348.                 EEdepNodeMenuItem;
  349.             menuItem -l "Lights" 
  350.                 -rb ($EEcurrNodeFilter == "lights") 
  351.                 -c ("EEobjFilterCB lights");
  352.             menuItem -l "Cameras" 
  353.                 -rb ($EEcurrNodeFilter == "cameras") 
  354.                 -c ("EEobjFilterCB cameras");
  355.             menuItem -l "Shaders" 
  356.                 -rb ($EEcurrNodeFilter == "shaders") 
  357.                 -c ("EEobjFilterCB shaders");
  358.  
  359.         if (`isTrue "DynamicsUIExists"`)
  360.         {
  361.             menuItem -l "Dynamics" -subMenu true;
  362.                 menuItem -l "Particles" 
  363.                     -rb ($EEcurrNodeFilter == "particles") 
  364.                     -c ("EEobjFilterCB particles");
  365.                 menuItem -l "Emitters" 
  366.                     -rb ($EEcurrNodeFilter == "emitters") 
  367.                     -c ("EEobjFilterCB emitters");
  368.                 menuItem -l "Springs" 
  369.                     -rb ($EEcurrNodeFilter == "springs") 
  370.                     -c ("EEobjFilterCB springs");
  371.                 menuItem -l "Gravity Fields" 
  372.                     -rb ($EEcurrNodeFilter == "gravity") 
  373.                     -c ("EEobjFilterCB gravity");
  374.                 menuItem -l "Drag Fields" 
  375.                     -rb ($EEcurrNodeFilter == "drag") 
  376.                     -c ("EEobjFilterCB drag");
  377.                 menuItem -l "Air Fields" 
  378.                     -rb ($EEcurrNodeFilter == "air") 
  379.                     -c ("EEobjFilterCB air");
  380.                 menuItem -l "Newton Fields" 
  381.                     -rb ($EEcurrNodeFilter == "newton") 
  382.                     -c ("EEobjFilterCB newton");
  383.                 menuItem -l "Radial Fields" 
  384.                     -rb ($EEcurrNodeFilter == "radial") 
  385.                     -c ("EEobjFilterCB radial");
  386.                 menuItem -l "Turbulence Fields" 
  387.                     -rb ($EEcurrNodeFilter == "turbulence") 
  388.                     -c ("EEobjFilterCB turbulence");
  389.                 menuItem -l "Uniform Fields" 
  390.                     -rb ($EEcurrNodeFilter == "uniform") 
  391.                     -c ("EEobjFilterCB uniform");
  392.                 menuItem -l "Vortex Fields" 
  393.                     -rb ($EEcurrNodeFilter == "vortex") 
  394.                     -c ("EEobjFilterCB vortex");
  395.                 menuItem -l "Rigid Bodies" 
  396.                     -rb ($EEcurrNodeFilter == "rigidBody") 
  397.                     -c ("EEobjFilterCB rigidBody");
  398.                 menuItem -l "Rigid Constraints" 
  399.                     -rb ($EEcurrNodeFilter == "rigidConstraint") 
  400.                     -c ("EEobjFilterCB constraint");
  401.             setParent -menu ..;
  402.         }
  403.  
  404.         if (`isTrue "KinematicsExists"`)
  405.         {
  406.             menuItem -l "Kinematics" -subMenu true;
  407.                 menuItem -l "Joints" 
  408.                     -rb ($EEcurrNodeFilter == "joint") 
  409.                     -c ("EEobjFilterCB joints");
  410.                 menuItem -l "Handles" 
  411.                     -rb ($EEcurrNodeFilter == "handle") 
  412.                     -c ("EEobjFilterCB handles");
  413.                 menuItem -l "IK Systems" 
  414.                     -rb ($EEcurrNodeFilter == "ikSystem") 
  415.                     -c ("EEobjFilterCB ikSystems");
  416.                 menuItem -l "IK Solvers" 
  417.                     -rb ($EEcurrNodeFilter == "ikSolver") 
  418.                     -c ("EEobjFilterCB ikSolvers");
  419.             setParent -menu ..;
  420.         }
  421.  
  422.  
  423.         if (`isTrue "DeformersExists"`)
  424.         {
  425.             menuItem -l "Deformers" -subMenu true;
  426.                 menuItem -l "Joint Lattice" 
  427.                     -rb ($EEcurrNodeFilter == "jointLattice") 
  428.                     -c ("EEobjFilterCB jointLattice");
  429.                 menuItem -l "Blend Shape" 
  430.                     -rb ($EEcurrNodeFilter == "blendShape") 
  431.                     -c ("EEobjFilterCB blendShape");
  432.                 menuItem -l "Bone Lattice" 
  433.                     -rb ($EEcurrNodeFilter == "boneLattice") 
  434.                     -c ("EEobjFilterCB boneLattice");
  435.                 menuItem -l "Cluster" 
  436.                     -rb ($EEcurrNodeFilter == "cluster") 
  437.                     -c ("EEobjFilterCB cluster");
  438.                 menuItem -l "Lattice" 
  439.                     -rb ($EEcurrNodeFilter == "lattice") 
  440.                     -c ("EEobjFilterCB lattice");
  441.                 menuItem -l "Sculpt" 
  442.                     -rb ($EEcurrNodeFilter == "sculpt") 
  443.                     -c ("EEobjFilterCB sculpt");
  444.                 menuItem -l "Wire" 
  445.                     -rb ($EEcurrNodeFilter == "wire") 
  446.                     -c ("EEobjFilterCB wire");
  447.             setParent -menu ..;
  448.         }
  449.  
  450.         setParent -m ..;
  451.         
  452.     menu -l "Attribute Filter" 
  453.         -familyImage "menuIconAttributeFilter.xpm"
  454.         EEattrFilterMenu;
  455.         radioMenuItemCollection;
  456.         menuItem -l "All " 
  457.             -rb ($EEcurrAttrFilter == "all") 
  458.             -c ("EEattrFilterCB all")
  459.             EEallAttrsMenuItem;
  460.         menuItem -l "Connected to Expressions" 
  461.             -rb ($EEcurrAttrFilter == "expr") 
  462.             -c ("EEattrFilterCB expr")
  463.             EEselAttrsMenuItem;
  464.     setParent -m ..;
  465.  
  466. global string $EEMathFunction[];
  467. global string $EEVectorFunction[];
  468. global string $EERandomFunction[];
  469. global string $EEConversionFunction[];
  470. global string $EEArrayFunction[];
  471. global string $EECurveFunction[];
  472.  
  473.     int $i = 0, $limit;
  474.  
  475.     menu -l "Insert Functions" EEInsertFuncMenu;
  476.         // Math Functions
  477.         //
  478.         menuItem -l "Math Functions" -sm true EEmathMI;
  479.         $limit = size($EEMathFunction);
  480.         for ($i = 0; $i < $limit; $i+=2) {    
  481.             menuItem -l $EEMathFunction[$i] -c ("EEmathFuncCB " + $i)
  482.                     -ann $EEMathFunction[$i+1];
  483.         }
  484.         setParent -menu ..;
  485.  
  486.         // Random Functions
  487.         //
  488.         menuItem -l "Random Functions" -sm true EErandMI;
  489.         $limit = size($EERandomFunction);
  490.         for ($i = 0; $i < $limit; $i+=2) {    
  491.             menuItem -l $EERandomFunction[$i] -c ("EErandFuncCB " + $i)
  492.                     -ann $EERandomFunction[$i+1];
  493.         }
  494.         setParent -menu ..;
  495.  
  496.         // Vector Functions
  497.         //
  498.         menuItem -l "Vector Functions" -sm true EEvectMI;
  499.         $limit = size($EEVectorFunction);
  500.         for ($i = 0; $i < $limit; $i+=2) {    
  501.             menuItem -l $EEVectorFunction[$i] -c ("EEvectFuncCB " + $i)
  502.                     -ann $EEVectorFunction[$i+1];
  503.         }
  504.         setParent -menu ..;
  505.  
  506.         // Conversion Functions
  507.         //
  508.         menuItem -l "Conversion Functions" -sm true EEconvMI;
  509.         $limit = size($EEConversionFunction);
  510.         for ($i = 0; $i < $limit; $i+=2) {    
  511.             menuItem -l $EEConversionFunction[$i] -c ("EEconvFuncCB " + $i)
  512.                     -ann $EEConversionFunction[$i+1];
  513.         }
  514.         setParent -menu ..;
  515.  
  516.         // Array Functions
  517.         //
  518.         menuItem -l "Array Functions" -sm true EEarrayMI;
  519.         $limit = size($EEArrayFunction);
  520.         for ($i = 0; $i < $limit; $i+=2) {    
  521.             menuItem -l $EEArrayFunction[$i] -c ("EEarrayFuncCB " + $i)
  522.                 -ann $EEArrayFunction[$i+1];
  523.         }
  524.         setParent -menu ..;
  525.  
  526.         // Curve Functions
  527.         // This block has distinct elements for the menu label
  528.         // (the first string in each set)
  529.         // and the literal string to insert in the expression (the second)
  530.         // in order to distinguish between the 2 overloaded
  531.         // versions of hermite().
  532.         //
  533.         menuItem -l "Curve Functions" -sm true EEcurveMI;
  534.         $limit = size($EECurveFunction);
  535.         for ($i = 0; $i < $limit; $i+=3) {    
  536.             menuItem -l $EECurveFunction[$i] -c ("EEcurveFuncCB " + $i)
  537.                     -ann $EECurveFunction[$i+2];
  538.         }
  539.         setParent -menu ..;
  540.  
  541.     setParent -menu ..;
  542.  
  543.     menu -l "Help" -helpMenu true EEhelpMenuItem;
  544.         menuItem -label "Help on Expression Editor..."
  545.             -enableCommandRepeat false
  546.             -command "showHelp ExpressionEditor";
  547.  
  548.     setParent -m ..;
  549.         
  550. }    // EEmakeMenubar
  551.  
  552.  
  553. //  ================ EEmakeFilterPopup ================
  554. //
  555. //  SYNOPSIS
  556. //        Make the popup menu for the object filter.
  557. //
  558. global proc    EEmakeFilterPopup()
  559. {
  560.     popupMenu EEnodePOP;
  561.  
  562.     menuItem -l "Select Filter" -sm true EEselectFilterPopMenu;
  563.         menuItem -l "By expression name" 
  564.             -c ("EEselectFilterCB expression");
  565.         menuItem -l "By object/attribute name" 
  566.             -c ("EEselectFilterCB object") ;
  567.         menuItem -l "By Script Node Name"
  568.             -c ("EEselectFilterCB scriptNode");
  569.     setParent -m ..;
  570.  
  571.     menuItem -l "Object Filter" -sm true EEobjFilterPopMenu;
  572.             menuItem -l "Selected Objects" 
  573.                 -c ("EEobjFilterCB allSelected");
  574.             menuItem -l "Dag Objects" 
  575.                 -c ("EEobjFilterCB dagObjects");
  576.             menuItem -l "Geometry Objects" 
  577.                 -c ("EEobjFilterCB geometry");
  578.             menuItem -l "Transforms" 
  579.                 -c ("EEobjFilterCB transforms");
  580.             menuItem -l "Dependency Nodes" 
  581.                 -c ("EEobjFilterCB depNodes");
  582.             menuItem -l "Lights" 
  583.                 -c ("EEobjFilterCB lights");
  584.             menuItem -l "Cameras" 
  585.                 -c ("EEobjFilterCB cameras");
  586.             menuItem -l "Shaders" 
  587.                 -c ("EEobjFilterCB shaders");
  588.  
  589.         if (`isTrue "DynamicsUIExists"`)
  590.         {
  591.             menuItem -l "Dynamics" -subMenu true;
  592.                 menuItem -l "Particles" 
  593.                     -c ("EEobjFilterCB particles");
  594.                 menuItem -l "Emitters" 
  595.                     -c ("EEobjFilterCB emitters");
  596.                 menuItem -l "Springs" 
  597.                     -c ("EEobjFilterCB springs");
  598.                 menuItem -l "Gravity Fields" 
  599.                     -c ("EEobjFilterCB gravity");
  600.                 menuItem -l "Drag Fields" 
  601.                     -c ("EEobjFilterCB drag");
  602.                 menuItem -l "Air Fields" 
  603.                     -c ("EEobjFilterCB air");
  604.                 menuItem -l "Newton Fields" 
  605.                     -c ("EEobjFilterCB newton");
  606.                 menuItem -l "Radial Fields" 
  607.                     -c ("EEobjFilterCB radial");
  608.                 menuItem -l "Turbulence Fields" 
  609.                     -c ("EEobjFilterCB turbulence");
  610.                 menuItem -l "Uniform Fields" 
  611.                     -c ("EEobjFilterCB uniform");
  612.                 menuItem -l "Vortex Fields" 
  613.                     -c ("EEobjFilterCB vortex");
  614.                 menuItem -l "Rigid Bodies" 
  615.                     -c ("EEobjFilterCB rigidBody");
  616.                 menuItem -l "Rigid Constraints" 
  617.                     -c ("EEobjFilterCB constraint");
  618.             setParent -menu ..;
  619.         }
  620.  
  621.  
  622.         if (`isTrue "KinematicsExists"`)
  623.         {
  624.             menuItem -l "Kinematics" -subMenu true;
  625.                 menuItem -l "Joints" 
  626.                     -c ("EEobjFilterCB joints");
  627.                 menuItem -l "Handles" 
  628.                     -c ("EEobjFilterCB handles");
  629.                 menuItem -l "IK Systems" 
  630.                     -c ("EEobjFilterCB ikSystems");
  631.                 menuItem -l "IK Solvers" 
  632.                     -c ("EEobjFilterCB ikSolvers");
  633.             setParent -menu ..;
  634.         }
  635.  
  636.         if (`isTrue "DeformersExists"`)
  637.         {
  638.             menuItem -l "Deformers" -subMenu true;
  639.                 menuItem -l "Joint Lattice" 
  640.                     -c ("EEobjFilterCB jointLattice");
  641.                 menuItem -l "Blend Shape" 
  642.                     -c ("EEobjFilterCB blendShape");
  643.                 menuItem -l "Bone Lattice" 
  644.                     -c ("EEobjFilterCB boneLattice");
  645.                 menuItem -l "Cluster" 
  646.                     -c ("EEobjFilterCB cluster");
  647.                 menuItem -l "Lattice" 
  648.                     -c ("EEobjFilterCB lattice");
  649.                 menuItem -l "Sculpt" 
  650.                     -c ("EEobjFilterCB sculpt");
  651.                 menuItem -l "Wire" 
  652.                     -c ("EEobjFilterCB wire");
  653.             setParent -menu ..;
  654.         }
  655.  
  656.         setParent -m ..;
  657.  
  658.     menuItem -l "Attribute Filter" -sm true EEattrFilterPopMenu;
  659.         menuItem -l "All" 
  660.             -c ("EEattrFilterCB all");
  661.         menuItem -l "Connected to Expressions" 
  662.             -c ("EEattrFilterCB expr");
  663.     setParent -m ..;
  664.  
  665. global string $EEMathFunction[];
  666. global string $EEVectorFunction[];
  667. global string $EERandomFunction[];
  668. global string $EEConversionFunction[];
  669. global string $EEArrayFunction[];
  670. global string $EECurveFunction[];
  671.  
  672.     int $i = 0, $limit;
  673.  
  674.     menuItem -l "Insert Functions" -sm true EEInsertFuncPopMenu;
  675.         // Math Functions
  676.         //
  677.         menuItem -l "Math Functions" -sm true;
  678.         $limit = size($EEMathFunction);
  679.         for ($i = 0; $i < $limit; $i+=2) {    
  680.             menuItem -l $EEMathFunction[$i] -c ("EEmathFuncCB " + $i)
  681.                     -ann $EEMathFunction[$i+1];
  682.         }
  683.         setParent -menu ..;
  684.  
  685.         // Random Functions
  686.         //
  687.         menuItem -l "Random Functions" -sm true;
  688.         $limit = size($EERandomFunction);
  689.         for ($i = 0; $i < $limit; $i+=2) {    
  690.             menuItem -l $EERandomFunction[$i] -c ("EErandFuncCB " + $i)
  691.                     -ann $EERandomFunction[$i+1];
  692.         }
  693.         setParent -menu ..;
  694.  
  695.         // Vector Functions
  696.         //
  697.         menuItem -l "Vector Functions" -sm true;
  698.         $limit = size($EEVectorFunction);
  699.         for ($i = 0; $i < $limit; $i+=2) {    
  700.             menuItem -l $EEVectorFunction[$i] -c ("EEvectFuncCB " + $i)
  701.                     -ann $EEVectorFunction[$i+1];
  702.         }
  703.         setParent -menu ..;
  704.  
  705.         // Conversion Functions
  706.         //
  707.         menuItem -l "Conversion Functions" -sm true;
  708.         $limit = size($EEConversionFunction);
  709.         for ($i = 0; $i < $limit; $i+=2) {    
  710.             menuItem -l $EEConversionFunction[$i] -c ("EEconvFuncCB " + $i)
  711.                     -ann $EEConversionFunction[$i+1];
  712.         }
  713.         setParent -menu ..;
  714.  
  715.         // Array Functions
  716.         //
  717.         menuItem -l "Array Functions" -sm true;
  718.         $limit = size($EEArrayFunction);
  719.         for ($i = 0; $i < $limit; $i+=2) {    
  720.             menuItem -l $EEArrayFunction[$i] -c ("EEarrayFuncCB " + $i)
  721.                 -ann $EEArrayFunction[$i+1];
  722.         }
  723.         setParent -menu ..;
  724.  
  725.         // Curve Functions
  726.         // This block has distinct elements for the menu label
  727.         // (the first string in each set)
  728.         // and the literal string to insert in the expression (the second)
  729.         // in order to distinguish between the 2 overloaded
  730.         // versions of hermite().
  731.         //
  732.         menuItem -l "Curve Functions" -sm true;
  733.         $limit = size($EECurveFunction);
  734.         for ($i = 0; $i < $limit; $i+=3) {
  735.             menuItem -l $EECurveFunction[$i] -c ("EEcurveFuncCB " + $i)
  736.                     -ann $EECurveFunction[$i+2];
  737.         }
  738.         setParent -menu ..;
  739.  
  740.     setParent -menu ..;
  741.  
  742. }    // EEmakeFilterPopup
  743.  
  744.  
  745. //
  746. //  ================ EEcreateWin ================
  747. //
  748. //  SYNOPSIS
  749. //      Create the expression editor window and its layout,
  750. //        and register the callbacks.
  751. //
  752. global proc EEcreateWin(string $winName)
  753. {
  754.     global int $EEcurrentEditor;
  755.     global int $EEisRuntime;
  756.  
  757.     // Create a new dialog and base container (mainForm).
  758.     //
  759.     int $wndHeight = 540;
  760.     // adjust the window height 
  761.     // so that all the controls get displayed correctly
  762.     if(`about -mac`)
  763.         $wndHeight = 600;
  764.         
  765.     window  
  766.         -t "Expression Editor" 
  767.         -in "Expressions" 
  768.         -ip -mb true 
  769.         -w 460 -h $wndHeight
  770.         -rtf false
  771.         $winName;
  772.  
  773.     EEmakeMenubar();
  774.  
  775.     frameLayout -bv false -cll false -lv false -mh 2 EEmainFrame;
  776.     formLayout -nd 100 EEmainForm;
  777.  
  778.     // Create the popup menu for the filters
  779.     //
  780.     EEmakeFilterPopup();
  781.  
  782.     // Create the Selection layout
  783.     //
  784.     formLayout -nd 100 EEselectionForm;
  785.  
  786.     // Attach the selection form to the main form 
  787.     //
  788.     formLayout -e 
  789.         -af EEselectionForm right 0
  790.         -af EEselectionForm left  0
  791.         -af EEselectionForm top   0
  792.         EEmainForm;
  793.  
  794.     columnLayout -adj true EEselectionCL;
  795.  
  796.     text -al "center" -l "Creating Expression" 
  797.         EEceModeT;
  798.  
  799.     // Create the expression name form and textfield.  Use text and 
  800.     // textField instead of textFieldGrp, in order to line the label
  801.     // and textfield up on the left side.
  802.     //
  803.     formLayout -nd 100 EEexprNameForm;
  804.  
  805.     text -al "left" -l "Expression Name" EEexprNameLabel;
  806.     textField 
  807.         -cc "EEexprNameTextCB"
  808.         -w 200 
  809.         EEexprNameT;
  810.     formLayout -e
  811.         -af EEexprNameLabel "left" 0 
  812.         -af EEexprNameLabel "top" 8
  813.         -ac EEexprNameT "left" 4 EEexprNameLabel
  814.         -aoc EEexprNameT "top" 0 EEexprNameLabel
  815.         EEexprNameForm;
  816.  
  817.     // Create the "New Expression" button.
  818.     //
  819.     button -l "New Expression" 
  820.          -c ("EEnewExpressionCB 1")
  821.          -w 120 -h 28 
  822.         -enable false
  823.          EEnewExpButton;
  824.     formLayout -e 
  825.          -ac EEnewExpButton left 4 EEexprNameT
  826.          -aoc EEnewExpButton top 0 EEexprNameT
  827.         EEexprNameForm;
  828.  
  829.     // Back up to EESelectionCL
  830.     //
  831.     setParent ..;
  832.  
  833.     // Make the selection frame -- the Node and Attributes Lists.
  834.     //
  835.     frameLayout -l "Selection"
  836.         -lv true -bv true -cll true -bs "etchedIn" -cl false -mh 4
  837.         EEselectionF;
  838.  
  839.     // Create the selection scrolled lists
  840.     //
  841.     formLayout -nd 100 EEselectFiltForm;
  842.  
  843.     formLayout -nd 100 EEnodeForm;
  844.  
  845.     formLayout -e
  846.         -af EEnodeForm         left     0
  847.         -af EEnodeForm         top     0
  848.         // -af EEnodeForm     bottom     0
  849.         EEselectFiltForm;
  850.  
  851.     text -al "left" -l "Objects" EEselectNamesL;
  852.     formLayout -e
  853.         -af EEselectNamesL left 0
  854.         -af EEselectNamesL top     2
  855.         EEnodeForm;
  856.  
  857.     textScrollList -ams false -nr 6 
  858.         -dcc "EEnodeListDblClickCB"
  859.         -sc "EEnodeListCB"
  860.         EEnodeList;
  861.     //    set the scroll list height, 
  862.     //    so that the scroll bars appear properly
  863.     if (`about -mac`) {
  864.         int $EEnodeListHeight = 110;
  865.         textScrollList -e 
  866.             -height $EEnodeListHeight
  867.             EEnodeList;
  868.     }
  869.  
  870.     formLayout -e
  871.         -af EEnodeList left     0
  872.         -af EEnodeList right     0
  873.         -af EEnodeList bottom     0
  874.         -ac EEnodeList top         2 EEselectNamesL
  875.         EEnodeForm;
  876.  
  877.     // Back up to EEselectFiltForm
  878.     //
  879.     setParent ..;
  880.  
  881.     // Make the attribute list
  882.     //
  883.     formLayout -nd 100 EEattrListForm;
  884.  
  885.     formLayout -e
  886.         -af EEattrListForm     top     0
  887.         -af EEattrListForm     right     0
  888.         -ap EEnodeForm         left     0     0 
  889.         -ap EEnodeForm         right     0     50
  890.         -ap EEattrListForm     left     2     50 
  891.         -ap EEattrListForm     right     0     100
  892.         EEselectFiltForm;
  893.  
  894.     text -al "left" -l "Attributes" EEattrNamesL;
  895.     formLayout -e
  896.         -af EEattrNamesL left     0
  897.         -af EEattrNamesL top     2
  898.         EEattrListForm;
  899.  
  900.     textScrollList -ams false -nr 6 
  901.         -sc "EEattrListCB"
  902.         -dcc "EEattrListDblClickCB"
  903.         EEattrList;
  904.  
  905.     //    set the scroll list height, 
  906.     //    so that the scroll bars appear properly
  907.     if (`about -mac`) {
  908.         int $EEattrListHeight = 110;
  909.         textScrollList -e 
  910.             -height $EEattrListHeight
  911.             EEattrList;
  912.     }
  913.     
  914.     formLayout -e
  915.         -af EEattrList left     0  
  916.         -af EEattrList right     0
  917.         -af EEattrList bottom     0
  918.         -ac EEattrList top         2 EEattrNamesL
  919.         EEattrListForm;
  920.  
  921.     setParent EEselectionCL;
  922.  
  923.     //    Create two tabs, one for expressions and the other for 
  924.     //    script nodes.
  925.     tabLayout -tv false -innerMarginWidth 0 -innerMarginHeight 0 EEoptionsTab;
  926.     columnLayout -adj true EEexprOptsCL;
  927.  
  928.     // Create the textfields for the selected and default nodes.
  929.     //
  930.     textFieldGrp -l "Selected Obj & Attr" 
  931.         -cc "EEselectedNodeAttrCB"
  932.         EEselNameT;
  933.  
  934.     textFieldGrp -l "Default Object" 
  935.         -cc "EEdefaultNodeCB"
  936.         EEdefNameT;
  937.  
  938.     checkBox -al "left" -l "Always Evaluate" 
  939.         -v true 
  940.         -cc "EEanimatedCB"
  941.         EEanimCBox;
  942.  
  943.     radioButtonGrp
  944.         -nrb 3
  945.         -l "Convert Units:"
  946.             -l1 "All"
  947.             -l2 "None"
  948.             -l3 "Angular only"
  949.             -cw 1 100 
  950.             -cw 2 60 
  951.             -cw 3 70 
  952.             -cw 4 100 
  953.             -sl 1
  954.             -on1 ("EEunitConversionCB all")
  955.             -on2 ("EEunitConversionCB none")
  956.             -on3 ("EEunitConversionCB angularOnly")
  957.         EEunitsRBG;
  958.  
  959.     radioButtonGrp
  960.         -nrb 2
  961.         -l "Particle:"
  962.             -l1 "Runtime"
  963.             -l2 "Creation"
  964.             -cw 1 100 
  965.             -cw 2 100 
  966.             -cw 3 110 
  967.             -on1 ("EErulesCB runtime")
  968.             -on2 ("EErulesCB creation")
  969.         EErulesRBG;
  970.  
  971.     if ($EEisRuntime)
  972.         radioButtonGrp -e -sl 1 EErulesRBG;
  973.     else
  974.         radioButtonGrp -e -sl 2 EErulesRBG;
  975.  
  976.     setParent EEoptionsTab;
  977.  
  978.     //    Create the UI for script nodes.
  979.     //
  980.     columnLayout -adj false EEscriptOptsCL;
  981.  
  982.     textFieldGrp -l "Selected Script Node" 
  983.         -cc "EEselectedScriptCB"
  984.         EEselScriptNodeNameT;
  985.  
  986.     rowLayout -nc 2
  987.         -cw 1 110
  988.         -cal 1 "left"
  989.         -cw 2 290
  990.         -cal 2 "left"
  991.         -cat 1 "both" 0
  992.         -cat 2 "left" 10
  993.         EEscriptNodeTypeRowL;
  994.  
  995.     text -l "Execute On:" -align "right";
  996.  
  997.     attrEnumOptionMenu -l ""
  998.         -ei 0 "Demand"
  999.         -ei 1 "Open/Close"
  1000.         -ei 2 "GUI Open/Close"
  1001.         -ei 3 "UI Configuration (Internal)"
  1002.         -ei 4 "Software Render"
  1003.         -ei 5 "Software Frame Render"
  1004.         -ei 6 "Scene Configuration (Internal)"
  1005.         EEscriptNodeTypeAOM;
  1006.     setParent ..;
  1007.  
  1008.     radioButtonGrp
  1009.         -nrb 2
  1010.         -l "Script:"
  1011.             -l1 "Before"
  1012.             -l2 "After"
  1013.             -cw 1 100 
  1014.             -cw 2 100 
  1015.             -cw 3 110 
  1016.             -on1 ("EEbeforeAfterScriptCB")
  1017.             -on2 ("EEbeforeAfterScriptCB")
  1018.             -sl 1
  1019.         EEscriptRBG;
  1020.  
  1021.     rowLayout -nc 2
  1022.         -cw 1 50
  1023.         -cal 1 "left"
  1024.         -cw 2 290
  1025.         -cal 2 "left"
  1026.         -cat 1 "both" 0
  1027.         -cat 2 "left" 10
  1028.         EEeditorRowL;
  1029.  
  1030.     text -l "";
  1031.     button     -l "Test Script" -align "center"
  1032.             -w 100 -c "EEscriptNodeTestCB" EEscriptNodeTestButton;
  1033.     setParent ..;
  1034.  
  1035.     tabLayout -edit -sti 1 EEoptionsTab;
  1036.     setParent EEmainForm;
  1037.  
  1038.     // Create the form for the multi-line scrolled text widget.
  1039.     //
  1040.     formLayout -nd 100 EEtextForm;
  1041.  
  1042.     // Attach the text form to the main form on right and left.
  1043.     //
  1044.     formLayout -e 
  1045.         -af EEtextForm right 0
  1046.         -af EEtextForm left 0
  1047.         -af EEtextForm bottom 0
  1048.         EEmainForm;
  1049.  
  1050.     // Attach the top of the text form to the bottom of the
  1051.     // selection form.
  1052.     //
  1053.     formLayout -e
  1054.         -ac EEtextForm top 0 EEselectionForm 
  1055.         EEmainForm;
  1056.  
  1057.     rowLayout -nc 2
  1058.         -cw 1 50
  1059.         -cal 1 "left"
  1060.         -cw 2 290
  1061.         -cal 2 "left"
  1062.         -cat 1 "both" 0
  1063.         -cat 2 "left" 10
  1064.         EEeditorRowL;
  1065.  
  1066.     text -l "Editor:" -align "right";
  1067.  
  1068.     // The evaluation version of Maya cannot launch external programs
  1069.     // so it cannot edit expressions with an external editor.
  1070.     //
  1071.     int $allowExtEdit = ! `about -evalVersion`;
  1072.  
  1073.     optionMenu -l "" 
  1074.         -cc EEeditorCB
  1075.         EEeditorOM;
  1076.  
  1077.         menuItem -l "Expression Editor" EEexprEdItem;
  1078.         if (`about -nt`) {
  1079.             menuItem -en $allowExtEdit -l "Text Editor" EEotherItem;
  1080.             // change the default width so that it works with
  1081.             // either large or small fonts.
  1082.             int $w = `optionMenu -q -w EEeditorOM`;
  1083.             optionMenu -e -w (int($w*1.3)) EEeditorOM;
  1084.         }
  1085.         else if (`about -irix`)
  1086.         {
  1087.             menuItem -en $allowExtEdit -l "jot" EEjotItem;
  1088.             menuItem -en $allowExtEdit -l "vi" EEviItem;
  1089.             menuItem -en $allowExtEdit -l "vim" EEvimItem;
  1090.             menuItem -en $allowExtEdit -l "xemacs" EExemacsItem;
  1091.             menuItem -en $allowExtEdit -l "Other" EEotherItem;
  1092.         }
  1093.         else if (`about -linux`)
  1094.         {
  1095.             menuItem -en $allowExtEdit -l "emacs" EEemacsItem;
  1096.             menuItem -en $allowExtEdit -l "gvim" EEgvimItem;
  1097.             menuItem -en $allowExtEdit -l "vi" EEviItem;
  1098.             menuItem -en $allowExtEdit -l "vim" EEvimItem;
  1099.             menuItem -en $allowExtEdit -l "xedit" EExeditItem;
  1100.             menuItem -en $allowExtEdit -l "xemacs" EExemacsItem;
  1101.             menuItem -en $allowExtEdit -l "Other" EEotherItem;
  1102.         }
  1103.  
  1104.     if ( `optionVar -exists EEexprEdTextEditor` && $allowExtEdit )
  1105.         $EEcurrentEditor = `optionVar -q EEexprEdTextEditor`;
  1106.  
  1107.     if ($EEcurrentEditor != 1)
  1108.         optionMenu -e -sl $EEcurrentEditor EEeditorOM;
  1109.  
  1110.     setParent ..;
  1111.  
  1112.     // Create the single-line text widget
  1113.     //    for displaying the method signature.
  1114.     //
  1115.     textField -text  "" 
  1116.                  -w 200 -editable false EEhelpField;
  1117.  
  1118.     // Create the multi-line scrolled text widget.
  1119.     //
  1120.     text -l "Expression:"
  1121.         EEtextLabel;
  1122.  
  1123.     string $path = `scrollField -ww false EEmultiText`;
  1124.  
  1125.     // Attach the textfield to the form.
  1126.     //
  1127.     formLayout -e
  1128.         -af EEeditorRowL top     0
  1129.         -af EEeditorRowL left     0 
  1130.          -ac EEtextLabel  top     4 EEeditorRowL
  1131.         -af EEtextLabel  left     0
  1132.          -ac EEmultiText  top     4 EEtextLabel
  1133.          -af EEmultiText  left     0
  1134.          -af EEmultiText  right     0
  1135.         -af EEmultiText  bottom 30
  1136.          -ac EEhelpField  top     4 EEmultiText
  1137.          -af EEhelpField  left     0
  1138.          -af EEhelpField  right     0
  1139.         -af EEhelpField  bottom 0
  1140.          EEtextForm;
  1141.  
  1142.     setParent ..;
  1143.  
  1144.     // Create the buttons at the bottom of the window. 
  1145.     //
  1146.     // Create the form for the apply, update and clear buttons 
  1147.     //
  1148.     formLayout -nd 100 EEbuttonsForm;
  1149.  
  1150.     // Attach the form to its parent, except on the top
  1151.     //
  1152.     formLayout -e
  1153.         -af EEbuttonsForm bottom 5
  1154.         -af EEbuttonsForm left      0
  1155.         -af EEbuttonsForm right  0
  1156.         EEmainForm;
  1157.  
  1158.     // Attach the bottom of the text form to the top of the
  1159.     // buttons form
  1160.     //
  1161.     formLayout -e
  1162.         -ac EEtextForm bottom 5 EEbuttonsForm 
  1163.         EEmainForm;
  1164.  
  1165.     // Lay out the buttons evenly across the form.
  1166.     //
  1167.     button -l "Create" -h 26 EEapplyButton;
  1168.     button -l "Delete" -h 26 -enable false EEdeleteButton;
  1169.     button -l "Reload" -h 26 -enable false EErestoreButton;
  1170.     button -l "Clear"  -h 26 EEclearButton;
  1171.     button -l "Close"  -h 26 EEcloseButton;
  1172.  
  1173.     formLayout -e
  1174.         -af EEapplyButton left  5
  1175.         -ap EEapplyButton right 3 20
  1176.  
  1177.         -ap EEdeleteButton left  2 20
  1178.         -ap EEdeleteButton right 3 40
  1179.  
  1180.         -ap EErestoreButton left  2 40
  1181.         -ap EErestoreButton right 3 60
  1182.  
  1183.         -ap EEclearButton left  2 60
  1184.         -ap EEclearButton right 3 80
  1185.  
  1186.         -ap EEcloseButton left  2 80
  1187.         -af EEcloseButton right 5
  1188.         EEbuttonsForm;
  1189.  
  1190.             setParent ..;
  1191.     setParent ..;
  1192.     
  1193.     if (`about -mac`)
  1194.     {
  1195.         setParent ..;
  1196.         setParent ..;
  1197.     }
  1198.  
  1199.     // Register the callbacks 
  1200.     //
  1201.     button -e -c "EEapplyCB" EEapplyButton;
  1202.     button -e -c "EEdeleteCB" EEdeleteButton;
  1203.     button -e -c "EErestoreCB" EErestoreButton;
  1204.     button -e -c "EEclearCB" EEclearButton;
  1205.     button -e -c "EEcloseCB" EEcloseButton;
  1206.  
  1207. }    // EEcreateWin
  1208.  
  1209.  
  1210. //  ================ EEpostConfirm ================
  1211. //
  1212. //  SYNOPSIS
  1213. //      Post a confirm dialog with theMessage.
  1214. //
  1215. global proc EEpostConfirm(string $theMessage)
  1216. {
  1217.     confirmDialog -t "Warning"
  1218.         -ma "left"
  1219.         -m  $theMessage
  1220.         -b "Close"
  1221.         -cb "Close";
  1222.  
  1223. }    // EEpostConfirm
  1224.  
  1225.  
  1226. //  ================ EEswitchSelectLayout ================
  1227. //
  1228. //  SYNOPSIS
  1229. //      Called when the Select Filter menu is changed.
  1230. //
  1231. global proc EEswitchSelectLayout(string $whichMethod)
  1232. {
  1233.     global string $EEnodeMode;
  1234.  
  1235.     if ($EEnodeMode == "scriptNode" || $whichMethod == "scriptNode") 
  1236.     {
  1237.         textField -e -tx "" EEexprNameT;
  1238.     }
  1239.  
  1240.     $EEnodeMode = $whichMethod;
  1241.  
  1242.     if ($whichMethod == "expression")
  1243.     {
  1244.         text -e -l "Expression Name" EEexprNameLabel;
  1245.         button -e -l "New Expression" EEnewExpButton;
  1246.  
  1247.         text -e -l "Expressions" EEselectNamesL;
  1248.         text -e -enable false EEattrNamesL;
  1249.         // Disable the filters menu and Selected Attribute textfield
  1250.         //
  1251.         menu -e -enable false EEobjFilterMenu; 
  1252.         menu -e -enable false EEattrFilterMenu; 
  1253.         menu -e -enable false EEobjFilterPopMenu; 
  1254.         menu -e -enable false EEattrFilterPopMenu; 
  1255.         textFieldGrp -e -tx "" EEselNameT;
  1256.         textFieldGrp -e -enable false EEselNameT;
  1257.  
  1258.         text -e -l "Expression:" EEtextLabel;
  1259.  
  1260.         tabLayout -e -sti 1 EEoptionsTab;
  1261.     }
  1262.     else if ($whichMethod == "object")
  1263.     {
  1264.         text -e -l "Expression Name" EEexprNameLabel;
  1265.         button -e -l "New Expression" EEnewExpButton;
  1266.  
  1267.         text -e -l "Objects" EEselectNamesL;
  1268.         text -e -enable true EEattrNamesL;
  1269.  
  1270.         // Enable the filter menus  and Selected Attribute textfield
  1271.         //
  1272.         menu -e -enable true EEobjFilterMenu; 
  1273.         menu -e -enable true EEattrFilterMenu; 
  1274.         menu -e -enable true EEobjFilterPopMenu; 
  1275.         menu -e -enable true EEattrFilterPopMenu; 
  1276.         textFieldGrp -e -enable true EEselNameT;
  1277.  
  1278.         text -e -l "Expression:" EEtextLabel;
  1279.  
  1280.         tabLayout -e -sti 1 EEoptionsTab;
  1281.     }
  1282.     else 
  1283.     {
  1284.         // Set the Editor for script nodes.
  1285.         //
  1286.         text -e -l "Script Node Name" EEexprNameLabel;
  1287.         button -e -l "New Script Node" EEnewExpButton;
  1288.  
  1289.         text -e -l "Script Nodes" EEselectNamesL;
  1290.         text -e -enable false EEattrNamesL;
  1291.  
  1292.         menu -e -enable false EEobjFilterMenu; 
  1293.         menu -e -enable false EEattrFilterMenu; 
  1294.         menu -e -enable false EEobjFilterPopMenu; 
  1295.         menu -e -enable false EEattrFilterPopMenu; 
  1296.         textFieldGrp -e -tx "" EEselNameT;
  1297.         textFieldGrp -e -enable false EEselNameT;
  1298.  
  1299.         textFieldGrp -e -enable true EEselScriptNodeNameT;
  1300.         text -e -l "Script:" EEtextLabel;
  1301.  
  1302.         tabLayout -e -sti 2 EEoptionsTab;
  1303.     }
  1304.  
  1305. }    // EEswitchSelectLayout
  1306.  
  1307.  
  1308. //  ================ EEswitchRulesForm ================
  1309. //
  1310. //  SYNOPSIS
  1311. //      Enable/disable some controls when switching between
  1312. //        particle and non-particle objects.
  1313. //
  1314. global proc EEswitchRulesForm(int $enable) 
  1315. {
  1316.     if ($enable)
  1317.     {
  1318.         radioButtonGrp -e -enable true EErulesRBG;
  1319.         radioButtonGrp -e -enable false EEunitsRBG;
  1320.         checkBox -e -enable false EEanimCBox;
  1321.     }
  1322.     else
  1323.     {
  1324.         radioButtonGrp -e -enable false EErulesRBG;
  1325.         radioButtonGrp -e -enable true EEunitsRBG;
  1326.         checkBox -e -enable true EEanimCBox;
  1327.     }
  1328. }
  1329.  
  1330.  
  1331. // *****************************************************************
  1332. //
  1333. //                EXPRESSION EDITOR QUERY PROCEDURES
  1334. //
  1335. // ******************************************************************
  1336.  
  1337.  
  1338. //  ================ EEgetCurrTypeList ================
  1339. //
  1340. //  SYNOPSIS
  1341. //     Get and return thelist of all objects in the scene
  1342. //        of the specified type.
  1343. //
  1344. global proc string[] EEgetCurrTypeList(string $currType)
  1345. {
  1346.     string $nodeList[];
  1347.  
  1348.     switch($currType)
  1349.     {
  1350.         case "allSelected": $nodeList = `ls -sl`;
  1351.                             break;
  1352.         case "dagObjects":    $nodeList = `ls -dag`;    
  1353.                             break;
  1354.         case "geometry":    $nodeList = `ls -geometry`;    
  1355.                             break;
  1356.         case "transforms":    $nodeList = `ls -transforms`;    
  1357.                             break;
  1358.         case "lights":        $nodeList = `ls -lights`;    
  1359.                             break;
  1360.         case "cameras":        $nodeList = `ls -cameras`;    
  1361.                             break;
  1362.         case "shaders":        $nodeList = `ls -materials`;    
  1363.                             break;
  1364.         case "depNodes":    $nodeList = `ls -dep`;    
  1365.                             break;
  1366.         case "joints":        $nodeList = `ls -type joint`;    
  1367.                             break;
  1368.         case "handles":        $nodeList = `ls -type ikHandle`;    
  1369.                             break;
  1370.         case "ikSystems":    $nodeList = `ls -type ikSystem`;    
  1371.                             break;
  1372.         case "ikSolvers":    $nodeList = `ls -type ikSolver`;
  1373.                             break;
  1374.         case "jointLattice":$nodeList = `ls -type jointLattice`;    
  1375.                             break;
  1376.         case "blendShape":    $nodeList = `ls -type blendShape`;    
  1377.                             break;
  1378.         case "boneLattice": $nodeList = `ls -type boneLattice`;    
  1379.                             break;
  1380.         case "cluster":        $nodeList = `ls -type cluster`;    
  1381.                             break;
  1382.         case "lattice":        $nodeList = `ls -type ffd`;    
  1383.                             break;
  1384.         case "sculpt":        $nodeList = `ls -type sculpt`;    
  1385.                             break;
  1386.         case "wire":        $nodeList = `ls -type wire`;    
  1387.                             break;
  1388.         case "scriptNode":    $nodeList = `ls -type script`;    
  1389.                             break;
  1390.     }
  1391.     if (`isTrue "DynamicsUIExists"`)
  1392.     {
  1393.         switch($currType)
  1394.         {
  1395.             case "particles":    $nodeList = `ls -type particle`;    
  1396.                                 break;
  1397.             case "emitters":    $nodeList = `ls -type pointEmitter`;    
  1398.                                 break;
  1399.             case "springs":        $nodeList = `ls -type spring`;    
  1400.                                 break;
  1401.             case "gravity":        $nodeList = `ls -type gravityField`;    
  1402.                                 break;
  1403.             case "drag":        $nodeList = `ls -type dragField`;    
  1404.                                 break;
  1405.             case "air":            $nodeList = `ls -type airField`;    
  1406.                                 break;
  1407.             case "newton":        $nodeList = `ls -type newtonField`;    
  1408.                                 break;
  1409.             case "radial":        $nodeList = `ls -type radialField`;    
  1410.                                 break;
  1411.             case "turbulence":    $nodeList = `ls -type turbulenceField`;    
  1412.                                 break;
  1413.             case "uniform":        $nodeList = `ls -type uniformField`;    
  1414.                                 break;
  1415.             case "vortex":        $nodeList = `ls -type vortexField`;    
  1416.                                 break;
  1417.             case "rigidBody":    $nodeList = `ls -type rigidBody`;    
  1418.                                 break;
  1419.             case "constraint":    $nodeList = `ls -type rigidConstraint`;    
  1420.                                 break;
  1421.         }
  1422.     }
  1423.     return $nodeList;
  1424.  
  1425. }    // EEgetCurrTypeList
  1426.  
  1427.  
  1428. //  ================ EEgetExpressionList ================
  1429. //
  1430. //
  1431. //  SYNOPSIS
  1432. //     Get and return the list of all expressions in the scene.
  1433. //
  1434. global proc string[] EEgetExpressionList()
  1435. {
  1436.     string $nodeList[];
  1437.     string $exprList[];
  1438.  
  1439.     // Get all the expression nodes.
  1440.     //
  1441.     $nodeList = `ls -type expression`;
  1442.  
  1443.     // Get all the particles that own expressions.
  1444.     //
  1445.     if (`isTrue "DynamicsUIExists"`)
  1446.     {
  1447.  
  1448.         string $particles[] = `ls -type particle`;
  1449.         string $attrs[];
  1450.         string $expr;
  1451.  
  1452.         int $pi, $ai, $exprCount = 0;
  1453.         for($pi = 0; $pi < size($particles); $pi++)
  1454.         {
  1455.             //
  1456.             // During file import AND referencing, Maya is put into
  1457.             // a new namespace, and the file is read into that space,
  1458.             // and all references to an object by name are considered
  1459.             // relative to that namespace.  It can be thought of as
  1460.             // a directory structure.  The "ls" command, however, always
  1461.             // returns the names relative to the global or root namespace.
  1462.             // Therefore, if we try to access them using those names, and
  1463.             // we are not in that global namespace, then we get "Object
  1464.             // not found" errors.  To get around this, we prepend ":" to
  1465.             // the names from "ls".  This tells Maya that this name is
  1466.             // to be considered relative to the global namespace.
  1467.             // It is only needed here, since it is only relavent to NEW
  1468.             // nodes nodes, and only this particle expression code actually
  1469.             // tries to use the names.
  1470.             //
  1471.             string $fullNamespaceName = (":"+$particles[$pi]);
  1472.             $expr = `dynExpression -q -r $fullNamespaceName`;
  1473.             if (size($expr) == 0)
  1474.             {
  1475.                 $expr = `dynExpression -q -c $fullNamespaceName`;
  1476.             }
  1477.  
  1478.             if (size($expr) > 0)
  1479.             {
  1480.                 $exprList[$exprCount] = $particles[$pi];
  1481.                 $exprCount++;
  1482.             }
  1483.         }
  1484.     
  1485.         int $ei, $ni;
  1486.         for ($ei = 0, $ni = size($nodeList); 
  1487.              $ei < size($exprList);  
  1488.              $ei++, $ni++)
  1489.     
  1490.         {
  1491.             $nodeList[$ni] = $exprList[$ei];
  1492.         }
  1493.     }
  1494.  
  1495.     return $nodeList;
  1496.  
  1497. }    // EEgetExpressionList
  1498.  
  1499.  
  1500. //  ================ EEgetAttrFromNode ================
  1501. //
  1502. //  SYNOPSIS
  1503. //
  1504. //        Find out if the current selected object has the
  1505. //        specified attribute.  If so, add it the the attributes
  1506. //        scrolled list, and return its index; if not, return -1.
  1507. //
  1508. global proc int EEgetAttrFromNode(string $attrName)
  1509. {
  1510.     global int $EEobjIsParticle;
  1511.  
  1512.     int $i, $found;
  1513.     int $attrIndex = -1;
  1514.     string $attrs[], $attrsShort[];
  1515.  
  1516.     string $selectedObj[] = `textScrollList -q -si EEnodeList`;
  1517.  
  1518.     // First look in the list of attribute long and short names.
  1519.     //
  1520.     $attrs = `listAttr -s -v -c -u -m $selectedObj[0]`;
  1521.  
  1522.     $attrsShort = `listAttr -sn -s -v -c -u -m $selectedObj[0]`;
  1523.     $found = 0;
  1524.     for ($i = 0; $i < size($attrs); $i++)
  1525.     {
  1526.         if ($attrs[$i] == $attrName || $attrsShort[$i] == $attrName)
  1527.         {
  1528.             $found = 1;
  1529.             // Make sure the long name is the one put in the attr list.
  1530.             //
  1531.             $attrName = $attrs[$i];
  1532.             break;
  1533.         }
  1534.     }
  1535.  
  1536.     // If not found, and if it's a particle, look in the list of array
  1537.     // attributes, long and short names.
  1538.     //
  1539.     if (!$found && $EEobjIsParticle)
  1540.     {
  1541.         clear($attrs);
  1542.         clear($attrsShort);
  1543.  
  1544.         $attrs = `listAttr -a -v -c -u -m $selectedObj[0]`;
  1545.         $attrsShort = `listAttr -sn -a -v -c -u -m $selectedObj[0]`;
  1546.  
  1547.         for ($i = 0; $i < size($attrs); $i++)
  1548.         {
  1549.             if ($attrs[$i] == $attrName || $attrsShort[$i] == $attrName)
  1550.             {
  1551.                 $found = 1;
  1552.                 // Make sure the long name is the one put in the attr list.
  1553.                 //
  1554.                 $attrName = $attrs[$i];
  1555.                 break;
  1556.             }
  1557.         }
  1558.     }
  1559.  
  1560.     // If the user typed a valid attribute name, put it in the
  1561.     // current attributes list and return the index (1-based).
  1562.     //
  1563.     if ($found)
  1564.     {
  1565.         textScrollList -e -a $attrName EEattrList;
  1566.         $attrIndex = `textScrollList -q -ni EEattrList`;
  1567.     }
  1568.  
  1569.     clear($attrs);
  1570.     clear($attrsShort);
  1571.     clear($selectedObj);
  1572.  
  1573.     return $attrIndex;
  1574.  
  1575. }    // EEgetAttrFromNode
  1576.  
  1577.  
  1578. //  ================ EEgetEditorMessage ================
  1579. //
  1580. //  SYNOPSIS
  1581. //      Return message re WINEDITOR.  Called by editorCB if the user
  1582. //        chooses "Other" in the option menu.
  1583. //
  1584. global proc string EEgetEditorMessage()
  1585. {
  1586.     return ("Set your own editor with preferred flags by setting the\nenvironment variable \"WINEDITOR\", if it is not already set.\nYou can set it at the command window or through the SGI\nDesktop menu --DeskTop/Desktop/Default Editor.\nWarning: the editor must be set to run in the foreground.\n");
  1587.  
  1588. }
  1589.  
  1590.  
  1591. //  ================ EEisValidNodeName ================
  1592. //
  1593. //  SYNOPSIS
  1594. //      Make sure the node name sent in is valid.
  1595. //
  1596. global proc int EEisValidNodeName(string $nodeName)
  1597. {
  1598.     string $result[] = `ls $nodeName`;
  1599.  
  1600.     int $status = 1;
  1601.  
  1602.     if (size($result) == 0)
  1603.     {
  1604.         
  1605.         warning ("Expression Editor: "+$nodeName+" is not a valid object name");
  1606.         $status = 0;
  1607.     }
  1608.     else if (size($result) > 1)
  1609.     {
  1610.         warning ("Expression Editor: more than one object matches the name: "+$nodeName);
  1611.         $status = 0;
  1612.     }
  1613.  
  1614.     clear($result);
  1615.     return $status;
  1616.  
  1617. }    // EEisValidNodeName
  1618.  
  1619.  
  1620. //  ================ EEexprNameExists ================
  1621. //
  1622. //  SYNOPSIS
  1623. //      Return if the name is of an existing expression
  1624. //
  1625. global proc int EEexprNameExists(string $exprName)
  1626. {
  1627.     string $allExprNames[] = EEgetExpressionList();
  1628.     int $i, $numExpressions;
  1629.     $numExpressions = size($allExprNames);
  1630.  
  1631.     int $nameExists = 0;
  1632.  
  1633.     for ($i = 0; $i < $numExpressions; $i++)
  1634.     {
  1635.         if ($allExprNames[$i] == $exprName)
  1636.         {
  1637.             $nameExists = 1;
  1638.             break;
  1639.         }
  1640.     }
  1641.     clear($allExprNames);
  1642.  
  1643.     return $nameExists;
  1644. }
  1645.  
  1646.  
  1647. //  ================ EEcheckValidExprName ================
  1648. //
  1649. //  SYNOPSIS
  1650. //      Make sure the expression name sent in is valid.
  1651. //
  1652. global proc int EEcheckValidExprName(string $exprName)
  1653. {
  1654.     global string $EEcurrExpressionName;
  1655.     int $nameValid = 1;
  1656.     string $exprName = `textField -q -tx EEexprNameT`;
  1657.  
  1658.     // The user can only name a new expression or change the
  1659.     // name of an expression being edited;  so if the name
  1660.     // the user typed is already the name of an expression node
  1661.     // then it is not valid, so remove it and restore the
  1662.     // previous name.
  1663.     //
  1664.     int $nameExists = EEexprNameExists($exprName);
  1665.  
  1666.     if ($nameExists)
  1667.     {
  1668.         $nameValid = 0;
  1669.         warning ("Expression Editor: name "+$exprName+" is already used. Restoring previous name.");
  1670.  
  1671.         // Name already exists, so is not valid to reuse, so restore the
  1672.         // previous name, or blank the field if there was no name.
  1673.         //
  1674.         if (size($EEcurrExpressionName) > 0)
  1675.             textField -e -tx $EEcurrExpressionName EEexprNameT;
  1676.         else
  1677.             textField -e -tx "" EEexprNameT; 
  1678.     }
  1679.  
  1680.     return $nameValid;
  1681.  
  1682. }    // EEcheckValidExprName
  1683.  
  1684.  
  1685. //  ================ EEnodeIsInList ================
  1686. //
  1687. //  SYNOPSIS
  1688. //        Return the index of the node in the scrolled list.
  1689. //        or -1 if it's not there.
  1690. //
  1691. global proc int EEnodeIsInList(string $nodeName)
  1692. {
  1693.     // If there is no object list, return "Not found".
  1694.     //
  1695.     if (`textScrollList -q -ni EEnodeList` == 0)
  1696.     {
  1697.         return -1;
  1698.     }
  1699.  
  1700.     // Get the list of object names.
  1701.     //
  1702.     string $listObjs[] = `textScrollList -q -ai EEnodeList`;
  1703.     int $currentObjSize = size($listObjs);
  1704.  
  1705.     int $objIndex = -1;
  1706.     int $i;
  1707.     for ($i = 0; $i < $currentObjSize; $i++)
  1708.     {
  1709.         if ($nodeName == $listObjs[$i]) 
  1710.         {
  1711.             // Found it; return the position in the list
  1712.             //
  1713.             $objIndex = $i;
  1714.             break;
  1715.         }
  1716.     }
  1717.  
  1718.     clear($listObjs);
  1719.  
  1720.     return $objIndex;
  1721.  
  1722. }    // EEnodeIsInList
  1723.  
  1724.  
  1725. //  ================ EEattrIsInList ================
  1726. //
  1727. //  SYNOPSIS
  1728. //
  1729. //        Return the index of the attribute in the scrolled list.
  1730. //        or -1 if it's not there.
  1731. //
  1732. global proc int EEattrIsInList(string $attrName)
  1733. {
  1734.     global int $EEobjIsParticle;
  1735.  
  1736.     string $listAttrsShort[];
  1737.     int $i;
  1738.  
  1739.     // If there is no attribute list, return "Not found".
  1740.     //
  1741.     if (`textScrollList -q -ni EEattrList` == 0)
  1742.         return -1;
  1743.  
  1744.     // Will need to test short and long name, so get the selected
  1745.     // object name to get the short list;  but get the long list from
  1746.     // the attribute list.  It was made using the same listAttr 
  1747.     // call, without -sn.
  1748.     //
  1749.     string $selectedObj[] = `textScrollList -q -si EEnodeList`;
  1750.     string $listAttrs[] = `textScrollList -q -ai EEattrList`;
  1751.  
  1752.     $listAttrsShort = `listAttr -sn -s -v -c -u -m -k $selectedObj[0]`;
  1753.  
  1754.     // If the object is a particle, we also want to get the array
  1755.     // attributes.
  1756.     //
  1757.     if ($EEobjIsParticle)
  1758.     {
  1759.         string $arrayAttrsShort[];
  1760.         int $attrSize;
  1761.         $arrayAttrsShort = `listAttr -sn -a -v -c -u -m $selectedObj[0]`;
  1762.         $attrSize = size($arrayAttrsShort);
  1763.         $listAttrSize = size($listAttrsShort);
  1764.  
  1765.         for ($i = 0; $i < $attrSize; $i++)
  1766.         {
  1767.             $listAttrsShort[$listAttrSize] = $arrayAttrsShort[$i];
  1768.             $listAttrSize++;
  1769.         }
  1770.     }
  1771.  
  1772.     $listAttrSize = size($listAttrs);
  1773.  
  1774.     int $attrIndex = -1;
  1775.     for ($i = 0; $i < $listAttrSize; $i++)
  1776.     {
  1777.         if (($attrName == $listAttrs[$i]) ||
  1778.             ($attrName == $listAttrsShort[$i]))
  1779.         {
  1780.             // Found it; return the position in the list (the
  1781.             // list is 1-based)
  1782.             //
  1783.             $attrIndex = $i + 1;
  1784.             break;
  1785.         }
  1786.     }
  1787.     clear($selectedObj);
  1788.     clear($listAttrs);
  1789.     clear($listAttrsShort);
  1790.  
  1791.     return $attrIndex;
  1792.  
  1793. }    // EEattrIsInList
  1794.  
  1795.  
  1796. // *****************************************************************
  1797. //
  1798. //        EXPRESSION EDITOR UI EDIT AND LIST MANAGEMENT PROCEDURES
  1799. //
  1800. // ******************************************************************
  1801.  
  1802.  
  1803. //  ================ EEsetCreateMode ================
  1804. //
  1805. //  SYNOPSIS
  1806. //     Set the editor state to create mode.
  1807. //
  1808. global proc EEsetCreateMode(string $createMessage)
  1809. {
  1810.     global int $EEcreateMode;
  1811.     global string $EEnodeMode;
  1812.  
  1813.     $EEcreateMode = 1;
  1814.     text -e -l $createMessage EEceModeT;
  1815.     button -e -l "Create" -w 100 -h 26 EEapplyButton;
  1816.     button -e -enable false EEdeleteButton;
  1817.     button -e -enable false EErestoreButton;
  1818.  
  1819.     if ($EEnodeMode == "scriptNode")
  1820.     {
  1821.         //    ScriptNodes: This control can not be queried. To eliminate any
  1822.         //    confusion, this control is disabled during creation.
  1823.         //
  1824.         attrEnumOptionMenu -e -enable false EEscriptNodeTypeAOM;
  1825.     }
  1826.  
  1827. }    // EEsetCreateMode
  1828.  
  1829.  
  1830. //  ================ EEsetEditMode ================
  1831. //
  1832. //  SYNOPSIS
  1833. //     Set the editor state to edit mode.
  1834. //
  1835. global proc EEsetEditMode(string $editMessage)
  1836. {
  1837.     global int $EEcreateMode;
  1838.     global string $EEnodeMode;
  1839.  
  1840.     $EEcreateMode = 0;
  1841.     text -e -l $editMessage EEceModeT;
  1842.     button -e -enable true EErestoreButton;
  1843.     button -e -l "Edit" -w 100 -h 26 EEapplyButton;
  1844.     button -e -enable true EEdeleteButton;
  1845.  
  1846.     if ($EEnodeMode == "scriptNode") 
  1847.     {
  1848.         //    ScriptNodes: This control can not be queried. To eliminate any
  1849.         //    confusion, this control is disabled during creation.
  1850.         //
  1851.         attrEnumOptionMenu -e -enable true EEscriptNodeTypeAOM;
  1852.     }
  1853. }    // EEsetEditMode
  1854.  
  1855.  
  1856. //  ================ EEclearAllControls ================
  1857. //
  1858. //  SYNOPSIS
  1859. //     Clear all the expression, node, attribute names/lists
  1860. //
  1861. global proc EEclearAllControls()
  1862. {
  1863.     global int $EEobjIsParticle;
  1864.     global int $EEpExpressionInEditor;
  1865.     global int $EEexpressionInEditor ;
  1866.     global string $EEcurrExpressionName;
  1867.     global string $EEorigExpressionName;
  1868.     global string $EEnodeMode;
  1869.  
  1870.     // Only clear the expression name if it exists, as otherwise the
  1871.     // user may have typed a new name to use it for the future.
  1872.     // Before clearing it, unregister the expression if it is registered.
  1873.     //
  1874.     string $exprName = `textField -q -tx EEexprNameT`;
  1875.     if (EEisParticle($exprName) ||
  1876.         size($exprName) && 
  1877.         (EEexprNameExists($exprName) || EEscriptNameExists($exprName)))
  1878.     {
  1879.         EEresetExpressionName("");
  1880.     }
  1881.  
  1882.     textFieldGrp -e -tx "" EEselNameT;
  1883.     textFieldGrp -e -tx "" EEdefNameT;
  1884.     scrollField -e -tx "" EEmultiText;
  1885.  
  1886.     checkBox -e -v 1 EEanimCBox;
  1887.     radioButtonGrp -e -sl 1 EEunitsRBG;
  1888.  
  1889.     if ($EEnodeMode != "scriptNode") 
  1890.     {
  1891.         if ($EEobjIsParticle)
  1892.             EEsetCreateMode("Creating Particle Expression");
  1893.         else
  1894.             EEsetCreateMode("Creating Expression");
  1895.     } 
  1896.     else 
  1897.     {
  1898.         EEsetCreateMode("Creating Script Node");
  1899.     }
  1900.  
  1901.     $EEcurrExpressionName = "";
  1902.     $EEorigExpressionName = "";
  1903.  
  1904.     // Nothing in editor means no expressions in files are
  1905.     // currently in the editor.
  1906.     //
  1907.     $EEpExpressionInEditor = -1;
  1908.     $EEexpressionInEditor = -1;
  1909.  
  1910.     //    Some script node controls
  1911.     textFieldGrp -e -tx "" EEselScriptNodeNameT;
  1912.  
  1913. }    // EEclearAllControls
  1914.  
  1915.  
  1916. //  ================ EEresetFilterToAll ================
  1917. //
  1918. //  SYNOPSIS
  1919. //        Reset the filter to "all dependency nodes" and rebuild
  1920. //        the object list
  1921. //
  1922. global proc EEresetFilterToAll(string $nodeName)
  1923. {
  1924.     global string $EEcurrNodeFilter;
  1925.     global string $EEnodeMode;
  1926.  
  1927.     // Check and see if the object selected is in the dag list,
  1928.     // if so, reset to it, otherwise reset to dependency nodes.
  1929.     //
  1930.     string $nodeList[] = `ls -dag`;    
  1931.     int $i;
  1932.     int $found = 0;
  1933.  
  1934.     if (size($nodeName) > 0)
  1935.     {
  1936.         for ($i = 0; $i < size($nodeList); $i++)
  1937.         {
  1938.             if ($nodeName == $nodeList[$i])
  1939.             {
  1940.                 $found = 1;
  1941.                 break;
  1942.             }
  1943.         }
  1944.     }
  1945.     if ($found || size($nodeName) == 0)
  1946.     {
  1947.         $EEcurrNodeFilter = "dagObjects";
  1948.         menuItem -e -rb true EEdagObjMenuItem;
  1949.     }
  1950.     else
  1951.     {
  1952.         $EEcurrNodeFilter = "depNodes";
  1953.         menuItem -e -rb true EEdepNodeMenuItem;
  1954.     }
  1955.     $EEnodeMode = "object";
  1956.     EErebuildNodeList("object");
  1957.  
  1958. }    // EEresetFilterToAll
  1959.  
  1960.  
  1961.  
  1962. //  ================ EEresetNodeControls ================
  1963. //
  1964. //  SYNOPSIS
  1965. //     Reset controls for a new selected object.
  1966. //
  1967. global proc EEresetNodeControls(string $nodeName)
  1968. {
  1969.     global int $EEobjIsParticle;
  1970.     global string $EEnodeMode;
  1971.     
  1972.     textFieldGrp -e -tx $nodeName -enable true EEselNameT;
  1973.  
  1974.     if (EEisParticle($nodeName))
  1975.     {
  1976.         $EEobjIsParticle = 1;
  1977.         EEswitchRulesForm(1);
  1978.         textFieldGrp -e -tx "" -enable false EEdefNameT;
  1979.         text -e -enable false EEexprNameLabel;
  1980.         EEresetExpressionName("");
  1981.  
  1982.         textField -e  -enable false EEexprNameT;
  1983.         EEsetCreateMode("Creating Particle Expression");
  1984.     }
  1985.     else
  1986.     {
  1987.         $EEobjIsParticle = 0;
  1988.         EEswitchRulesForm(0);
  1989.         text -e -enable true EEexprNameLabel;
  1990.  
  1991.         // Only clear the expression name if it exists, as otherwise the
  1992.         // user may have typed a new name to use it for the future.
  1993.         //
  1994.         string $exprName = `textField -q -tx EEexprNameT`;
  1995.  
  1996.         if ($EEnodeMode == "scriptNode") 
  1997.         {
  1998.             textFieldGrp -e -tx "" -enable false EEdefNameT;
  1999.             if (size($exprName) && EEscriptNameExists($exprName))
  2000.             {
  2001.                 EEresetExpressionName("");
  2002.                 // textField -e -tx "" EEexprNameT;
  2003.                 EEsetCreateMode("Creating Script Node");
  2004.             }
  2005.         }
  2006.         else 
  2007.         {
  2008.             textFieldGrp -e -tx $nodeName -enable true EEdefNameT;
  2009.             if (size($exprName) && EEexprNameExists($exprName))
  2010.             {
  2011.                 EEresetExpressionName("");
  2012.                 // textField -e -tx "" EEexprNameT;
  2013.                 EEsetCreateMode("Creating Expression");
  2014.             }
  2015.         }
  2016.  
  2017.         textField -e -enable true EEexprNameT;
  2018.     }
  2019.  
  2020.     if ($EEnodeMode == "scriptNode") 
  2021.     {
  2022.         textFieldGrp -e -tx $nodeName -enable true EEselScriptNodeNameT;
  2023.     } 
  2024.     else 
  2025.     {
  2026.         //  Load the name of the objects attributes into the editor's list.
  2027.         //
  2028.         textFieldGrp -e -tx $nodeName -enable true EEselNameT;
  2029.         EErebuildAttrList($nodeName);
  2030.     }
  2031.  
  2032. }    // EEresetNodeControls
  2033.  
  2034.  
  2035. //  ================ EErebuildNodeList ================
  2036. //
  2037. //  SYNOPSIS
  2038. //        Rebuild the list of objects for the expression editor
  2039. //
  2040. global proc EErebuildNodeList(string $whichList)
  2041. {
  2042.     global string $EEcurrNodeFilter;
  2043.     global string $EEcurrSelectedNode;
  2044.     global string $EEorigExpressionName;
  2045.     global string $EEcurrExpressionName;
  2046.     global int $EEcreateMode;
  2047.     global int $EEobjIsParticle;
  2048.  
  2049.     int $i;
  2050.  
  2051.     string $nodeList[];
  2052.  
  2053.     // First pick up the current and orig expression names, so we can
  2054.     // reinstate, if desired.
  2055.     //
  2056.     string $currExprName = `textField -q -tx EEexprNameT`;
  2057.  
  2058.     string $origExprName = $EEorigExpressionName;
  2059.  
  2060.     // Clear the old object and attribute lists. But first, make
  2061.     // sure messages have been stopped for them.
  2062.     //
  2063.     $nodeList = `textScrollList -q -ai EEnodeList`;
  2064.     for ($i = 0; $i < size($nodeList); $i++)
  2065.     {
  2066.         EEremoveNodeFromList($nodeList[$i], 1);
  2067.     }
  2068.     $EEcurrSelectedNode = "";
  2069.  
  2070.     textScrollList -e -ra EEattrList;
  2071.  
  2072.     // Get the list of expression or objects of the selected type.
  2073.     //
  2074.     if ($whichList == "expression")
  2075.         $nodeList = EEgetExpressionList();
  2076.     else if ($whichList == "scriptNode") 
  2077.         $nodeList = EEgetCurrTypeList("scriptNode");
  2078.     else
  2079.         $nodeList = EEgetCurrTypeList($EEcurrNodeFilter);
  2080.  
  2081.     if (size($nodeList) == 0)
  2082.     {
  2083.         EEclearAllControls();
  2084.         return;
  2085.     }
  2086.  
  2087.     // Make the object list in the UI, and register to listen to
  2088.     // changes in each node.
  2089.     //
  2090.     string $newNode;
  2091.     string $prevNewNode;
  2092.  
  2093.     for ($i = 0; $i < size($nodeList); $i++)
  2094.     {
  2095.         string $buffer[];
  2096.         tokenize($nodeList[$i], ".", $buffer);
  2097.  
  2098.         // If the buffer has more than two items in it, the first item
  2099.         // will be the node name and the others attribute names, 
  2100.         // e.g. "cv".  So, strip $nodeName to just the node name,
  2101.         // and the rest  will go into the attr list.
  2102.         //
  2103.         if (size($buffer) >= 2 )
  2104.         {
  2105.             $newNode = $buffer[0];
  2106.             if ($newNode != $prevNewNode)
  2107.             {
  2108.                 EEaddNodeToList($newNode);
  2109.                 $prevNewNode = $newNode;
  2110.             }
  2111.         }
  2112.         else
  2113.         {
  2114.             EEaddNodeToList($nodeList[$i]);
  2115.         }
  2116.     }
  2117.  
  2118.     string $currObjAttrName;
  2119.  
  2120.     if ($whichList == "expression")
  2121.     {
  2122.         // If switching to expression mode, and an expression is
  2123.         // in the editor, make it the selected item in the list,
  2124.         // otherwise clear all controls.
  2125.         //
  2126.         // Get the name of the obj.attr the expression is connected to
  2127.         //
  2128.         if (size($currExprName) > 0 && !$EEcreateMode)
  2129.         {
  2130.             if ($EEobjIsParticle)
  2131.             {
  2132.                 // Expression name and obj.attr name are the same for
  2133.                 // particles.
  2134.                 //
  2135.                 $currObjAttrName = $currExprName;
  2136.             }
  2137.             else
  2138.             {
  2139.                 string $objAttr[] = 
  2140.                     `listConnections -s false -d true -shapes true -plugs true  -scn true  $currExprName`;
  2141.                 $currObjAttrName = $objAttr[0];
  2142.             }
  2143.             EEselectNodeInList($currExprName);
  2144.  
  2145.             textFieldGrp -e -tx $currObjAttrName EEselNameT;
  2146.             $EEorigExpressionName = $origExprName;
  2147.             $EEcurrExpressionName = $currExprName;
  2148.         }
  2149.         else
  2150.         {
  2151.             EEclearAllControls();
  2152.         }
  2153.     }
  2154.     else if ($whichList == "object")
  2155.     {
  2156.         // If switching to object/filter mode, and an object is in the 
  2157.         // editor, if it's in the new list, make it the selected item 
  2158.         // in the list, build its attribute list, and make the current
  2159.         // attribute selected.  If it's not in the list, make the
  2160.         // first item in the new list selected and get its attribute list.
  2161.         //
  2162.         $currObjAttrName = `textFieldGrp -q -tx EEselNameT`;
  2163.  
  2164.         if (size($currObjAttrName) > 0)
  2165.         {
  2166.             string $buffer[];
  2167.             tokenize($currObjAttrName, ".", $buffer);
  2168.             $currentObj = $buffer[0];
  2169.             $currentAttr = $buffer[1];
  2170.  
  2171.             if (EEnodeIsInList($currentObj) > -1)
  2172.             {
  2173.                 EEnewSelectedNode($currentObj);
  2174.  
  2175.                 if ((size($currentAttr) > 0) && 
  2176.                     (($attrListIndex = EEattrIsInList($currentAttr)) > -1))
  2177.                 {
  2178.                     EEnewSelectedAttr($attrListIndex);
  2179.                 }
  2180.                 return;
  2181.             }
  2182.         }
  2183.         EEclearAllControls();
  2184.  
  2185.         // Either there's no object name current or the current one
  2186.         // is not in the new list, so if there is an object list, make
  2187.         // the first item selected, build its attribute list, and set
  2188.         // the object name in the selected obj/attr textfield.
  2189.         //
  2190.         if (`textScrollList -q -ni EEnodeList` > 0)
  2191.         {
  2192.             textScrollList -e -sii 1 EEnodeList;
  2193.             string $theObj[] = `textScrollList -q -si EEnodeList`;
  2194.             EEnewSelectedNode($theObj[0]);
  2195.         }
  2196.     } 
  2197.     else
  2198.     {
  2199.         // If switching to script node mode, and an object is in the 
  2200.         // editor, if it's in the new list, make it the selected item 
  2201.         // in the list.  If it's not in the list, make the
  2202.         // first item in the new list selected and get its attribute list.
  2203.         //
  2204.         string $currNodeName = `textField -q -tx EEexprNameT`;
  2205.  
  2206.         if (size($currNodeName) > 0)
  2207.         {
  2208.             EEnewSelectedNode($currNodeName);
  2209.  
  2210.             if (!$EEcreateMode)
  2211.             {
  2212.                 textFieldGrp -e -tx $currNodeName EEselScriptNodeNameT;
  2213.                 $EEorigExpressionName = $origExprName;
  2214.                 $EEcurrExpressionName = $currExprName;
  2215.             }
  2216.         }
  2217.         else
  2218.         {
  2219.             EEclearAllControls();
  2220.         }
  2221.     }
  2222.  
  2223.     clear($nodeList);
  2224.     
  2225. }    // EErebuildNodeList
  2226.  
  2227.  
  2228. //  ================ EErebuildAttrList ================
  2229. //
  2230. //  SYNOPSIS
  2231. //        Rebuild the list of attributes for the expression editor
  2232. //
  2233. global proc    EErebuildAttrList(string $nodeName)
  2234. {
  2235.     global string $EEcurrAttrFilter;
  2236.     global int $EEobjIsParticle;
  2237.  
  2238.     int $i;
  2239.  
  2240.     // Get the object's attribute list; clear the current
  2241.     // attribute list from the attribute scroll list, and put 
  2242.     // the new list in the control, and the object name in
  2243.     // the editor default object textfield.
  2244.     //
  2245.     string $objAttrs[] = `listAttr -s -v -c -u -m -k $nodeName`;
  2246.  
  2247.     if ($EEobjIsParticle)
  2248.     {
  2249.         string $arrayAttrs[];
  2250.         int $attrSize;
  2251.  
  2252.         $arrayAttrs = `listAttr -a -v -c -u -m $nodeName`;
  2253.         $arrayAttrSize = size($arrayAttrs);
  2254.         $attrSize = size($objAttrs);
  2255.  
  2256.         for ($i = 0; $i < $arrayAttrSize; $i++)
  2257.         {
  2258.             $objAttrs[$attrSize] = $arrayAttrs[$i];
  2259.             $attrSize++;
  2260.         }
  2261.     }
  2262.  
  2263.     textScrollList -e -ra EEattrList;
  2264.  
  2265.     if ($EEcurrAttrFilter == "all")
  2266.     {
  2267.         for ($i = 0; $i < size($objAttrs); $i++)
  2268.         {
  2269.             if (!$EEobjIsParticle || EEisValidDynAttr($objAttrs[$i]))
  2270.                 textScrollList -e -a $objAttrs[$i] EEattrList;
  2271.         }
  2272.     }
  2273.     else
  2274.     {
  2275.         // List only attributes that have expressions.
  2276.         // Find out if there's an expression node connected to the
  2277.         // attribute, if there is one, add the attribute to the
  2278.         // list.
  2279.         //
  2280.         string $objAttrName;
  2281.         string $exprName[];
  2282.         string $particleExpr;
  2283.  
  2284.         for ($i = 0; $i < size($objAttrs); $i++)
  2285.         {
  2286.             if (!$EEobjIsParticle)
  2287.             {
  2288.                 $objAttrName = ($nodeName+"."+$objAttrs[$i]);
  2289.                 $exprName = 
  2290.                     `listConnections -s true -d false -t "expression"  -scn true  $objAttrName`;
  2291.                 if (size($exprName[0]) > 0)
  2292.                 {
  2293.                     textScrollList -e -a $objAttrs[$i] EEattrList;
  2294.                 }
  2295.             }
  2296.             else
  2297.             {
  2298.                 $particleExpr =
  2299.                     `dynExpression -q -r $nodeName`;
  2300.                 if (size($particleExpr) == 0)
  2301.                 {
  2302.                     $particleExpr = 
  2303.                         `dynExpression -q -c $nodeName`;
  2304.                 }
  2305.                 else if (size($particleExpr) > 0)
  2306.                 {
  2307.                     textScrollList -e -a $objAttrs[$i] EEattrList;
  2308.                 }
  2309.             }
  2310.         }
  2311.     }
  2312. }    // EErebuildAttrList
  2313.  
  2314.  
  2315. // 
  2316. //  ================ EEupdateExprList ================
  2317. //
  2318. //  SYNOPSIS
  2319. //        Update the expression list when a name has changed.
  2320. //
  2321. global proc EEupdateExprList()
  2322. {
  2323.     global string $EEorigExpressionName;
  2324.     global string $EEcurrExpressionName;
  2325.     global string $EEnodeMode;
  2326.  
  2327.     // If the user has changed the expression name, and is in
  2328.     // select-by-expression mode, update the list with the new
  2329.     // name.
  2330.     //
  2331.     if ($EEorigExpressionName != $EEcurrExpressionName)
  2332.     {
  2333.            if ($EEnodeMode == "expression" || $EEnodeMode == "scriptNode")
  2334.         {
  2335.             EEremoveNodeFromList($EEorigExpressionName, 0);
  2336.  
  2337.             EEaddNodeToList($EEcurrExpressionName);
  2338.  
  2339.             // Select the node.
  2340.             //
  2341.             EEselectNodeInList($EEcurrExpressionName);
  2342.  
  2343.         }
  2344.         $EEorigExpressionName = $EEcurrExpressionName;
  2345.     }
  2346.  
  2347. }    // EEupdateExprList
  2348.  
  2349.  
  2350. //  ================ EEaddNodeToList ================
  2351. //
  2352. //  SYNOPSIS
  2353. //
  2354. //        Add a node to the expression/object list, if it's not already
  2355. //        there.
  2356. //
  2357. global proc EEaddNodeToList(string $nodeName)
  2358. {
  2359.     // Listen for changes in the node, then add it.
  2360.     //
  2361.     expressionEditorListen -ln $nodeName;
  2362.  
  2363.     if (EEnodeIsInList($nodeName) == -1)
  2364.         textScrollList -e -a $nodeName EEnodeList;
  2365.  
  2366. }    // EEaddNodeToList
  2367.  
  2368.  
  2369. //  ================ EEremoveNodeFromList ================
  2370. //
  2371. //  SYNOPSIS
  2372. //
  2373. //        Remove a node from the expression/object list.
  2374. //
  2375. global proc EEremoveNodeFromList(string $nodeName, int $removeExpr)
  2376. {
  2377.     global string $EEorigExpressionName;
  2378.     global string $EEcurrExpressionName;
  2379.     global string $EEcurrSelectedNode;
  2380.  
  2381.     // Stop listening for changes in the node, then remove it.
  2382.     //
  2383.     expressionEditorListen -sln $nodeName;
  2384.  
  2385.     string $selected[] = `textScrollList -q -si EEnodeList`;
  2386.     if (size($selected) > 0 && $nodeName == $selected[0])
  2387.     {
  2388.         expressionEditorListen -sla $nodeName;
  2389.  
  2390.         // If the flag says to, remove the
  2391.         // expression from the expression field.
  2392.         //
  2393.         if ($removeExpr)
  2394.         {
  2395.             EEresetExpressionName("");
  2396.             $EEcurrExpressionName = "";
  2397.             $EEorigExpressionName = "";
  2398.             $EEcurrSelectedNode = "";
  2399.         }
  2400.     }
  2401.  
  2402.     if (EEnodeIsInList($nodeName) > -1)
  2403.         textScrollList -e -ri $nodeName EEnodeList;
  2404.  
  2405. }    // EEremoveNodeFromList
  2406.  
  2407.  
  2408. //  ================ EEselectNodeInList ================
  2409. //
  2410. //  SYNOPSIS
  2411. //
  2412. //        Select a node in the expression/object list.
  2413. //
  2414. global proc EEselectNodeInList(string $nodeName)
  2415. {
  2416.     global string $EEcurrSelectedNode;
  2417.     global string $EEnodeMode;
  2418.  
  2419.     // Stop listening for attribute changes in the current selected
  2420.     // selected object; select the new node and set it up to
  2421.     // listen for attribute changes.
  2422.     //
  2423.     if (size($EEcurrSelectedNode) > 0)
  2424.     {
  2425.         expressionEditorListen -sla $EEcurrSelectedNode;
  2426.     }
  2427.     textScrollList -e -si $nodeName EEnodeList;
  2428.  
  2429.     // If in expression mode, then the selected node is an
  2430.     // expression, so also should go in the expression name
  2431.     // field.
  2432.     //
  2433.     if ($EEnodeMode == "expression" || $EEnodeMode == "scriptNode")
  2434.         textField -e -tx $nodeName EEexprNameT;
  2435.  
  2436.     $EEcurrSelectedNode = $nodeName;
  2437.     expressionEditorListen -la $nodeName;
  2438.  
  2439. }    // EEselectNodeInList
  2440.  
  2441.  
  2442. // 
  2443. //  ================ EEnewSelectedNode ================
  2444. //
  2445. //  SYNOPSIS
  2446. //      Make the object selected, and load its
  2447. //        attribute list into the editor's attribute list.
  2448. //
  2449. global proc EEnewSelectedNode(string $nodeName)
  2450. {
  2451.     int $EEobjIsParticle;
  2452.  
  2453.     EEclearAllControls();
  2454.     EEresetNodeControls($nodeName);
  2455.  
  2456.     // Show the object selected, and register it to get attribute
  2457.     // added/removed messages.
  2458.     //
  2459.     EEselectNodeInList($nodeName);
  2460.  
  2461.     // If the new node is a particle, get its expression, if it has
  2462.     // one.
  2463.     //
  2464.     if (EEisParticle($nodeName))
  2465.     {
  2466.         string $particleExpr = EEgetParticleExpression($nodeName, "");
  2467.         if (size($particleExpr) == 0)
  2468.             EEdisplayNoExpression($nodeName);
  2469.         else
  2470.             EEdisplayParticleExpression($nodeName, $particleExpr);
  2471.     }
  2472.  
  2473. }    // EEnewSelectedNode
  2474.  
  2475.  
  2476. //  ================ EEnewSelectedAttr ================
  2477. //
  2478. //  SYNOPSIS
  2479. //      Load a new attribute from the attribute list into the editor.
  2480. //
  2481. global proc EEnewSelectedAttr(int $attrIndex)
  2482. {
  2483.     // Get the selected object
  2484.     //
  2485.     string $selectedObj[] = `textScrollList -q -si EEnodeList`;
  2486.  
  2487.     //    Make the attribute  selected and put the object.attribute 
  2488.     //  name in the selected object/attribute textfield; 
  2489.     //
  2490.     textScrollList -e -sii $attrIndex EEattrList;
  2491.     textScrollList -e  -shi $attrIndex EEattrList;
  2492.  
  2493.     // Make sure we have the long name of the attribute.
  2494.     //
  2495.     string $names[] = `textScrollList -q -si EEattrList`;
  2496.     string $attrName = $names[0];
  2497.  
  2498.     EEloadNewNodeAttr($selectedObj[0], $attrName);
  2499.  
  2500. }    // EEnewSelectedAttr
  2501.  
  2502.  
  2503. //  ================ EEloadNewNodeAttr ================
  2504. //
  2505. //  SYNOPSIS
  2506. //
  2507. //        Load a new object.attribute and its expression into
  2508. //        the editor.
  2509. //
  2510. global proc EEloadNewNodeAttr(string $nodeName, string $attrName)
  2511. {
  2512.     global int $EEobjIsParticle;
  2513.     string $objAttrName;
  2514.  
  2515.     $objAttrName = ($nodeName+"."+$attrName);
  2516.  
  2517.     // Display the expression for this attribute, if there is one.
  2518.     //
  2519.     EEdisplayAttrExpr($objAttrName);
  2520.  
  2521.     textFieldGrp -e -tx $objAttrName EEselNameT;
  2522.  
  2523.     // User may have sent in a short name, so find the attribute in the list
  2524.     // checking both short and long names, then select it.
  2525.     //
  2526.     if (($attrListIndex = EEattrIsInList($attrName)) > -1)
  2527.     {
  2528.         textScrollList -e -sii $attrListIndex EEattrList;
  2529.         textScrollList -e -shi $attrListIndex EEattrList;
  2530.     }
  2531.  
  2532. }    // EEloadNewNodeAttr
  2533.  
  2534.  
  2535. //  ================ EEdisplayAttrExpr ================
  2536. //
  2537. //  SYNOPSIS
  2538. //      Display the expression connected to the current
  2539. //      object.attribute in the scrolled textfield, and
  2540. //        put the name in the expression name textfield.
  2541. //
  2542. global proc EEdisplayAttrExpr(string $objAttrName)
  2543. {
  2544.     global int $EEobjIsParticle;
  2545.  
  2546.     if (!$EEobjIsParticle)
  2547.     {
  2548.         string $exprName[] = 
  2549.             `listConnections -s true -d false -t "expression" -scn true $objAttrName`;
  2550.  
  2551.         // If the obj.attr has an expression,  load it; otherwise
  2552.         // clear and reset the controls.
  2553.         //
  2554.         if (size($exprName[0]) == 0)
  2555.             EEdisplayNoExpression($objAttrName);
  2556.         else
  2557.             EEdisplayExpression($exprName[0]);
  2558.  
  2559.         clear($exprName);
  2560.     }
  2561.     else
  2562.     {
  2563.         string $particleExpr;
  2564.         string $buffer[];
  2565.         tokenize($objAttrName, ".", $buffer);
  2566.  
  2567.         $particleExpr = EEgetParticleExpression($buffer[0], $buffer[1]);
  2568.  
  2569.         if (size($particleExpr) == 0)
  2570.         {
  2571.             EEdisplayNoExpression($objAttrName);
  2572.             EEswitchRulesForm(1);
  2573.         }
  2574.         else
  2575.         {
  2576.             if (EEisDynExpression($objAttrName))
  2577.             {
  2578.                 EEdisplayParticleExpression($buffer[0], $particleExpr);
  2579.                 EEswitchRulesForm(1);
  2580.             }
  2581.             else
  2582.             {
  2583.                 string $exprName[] = 
  2584.                     `listConnections -s true -d false -t "expression" -scn true $objAttrName`;
  2585.                 EEdisplayExpression($exprName[0]);
  2586.                 EEswitchRulesForm(0);
  2587.             }
  2588.         }
  2589.     }
  2590.  
  2591. }    // EEdisplayAttrExpr
  2592.  
  2593.  
  2594. //  ================ EEdisplayNoExpression ================
  2595. //
  2596. //  SYNOPSIS
  2597. //      Set the controls for no expression.
  2598. //
  2599. //
  2600. global proc EEdisplayNoExpression(string $objAttrName)
  2601. {
  2602.     global int $EEcurrentEditor;
  2603.     global int $EEdoLaunchTextEd;
  2604.     global string $EEcurrExpressionName;
  2605.     global string $EEorigExpressionName;
  2606.     global int $EEobjIsParticle;
  2607.     global int $EEexpressionInEditor;
  2608.     global int $EEpExpressionInEditor;
  2609.     global string $EEnodeMode;
  2610.  
  2611.     // Only clear the expression name if it exists or is a particle
  2612.     // name, as otherwise the user may have typed a new name to use it
  2613.     // for the future.
  2614.     //
  2615.     string $exprName = `textField -q -tx EEexprNameT`;
  2616.  
  2617.     int $isParticle = EEisParticle($exprName);
  2618.     if ( (size($exprName)) && 
  2619.          ($isParticle || EEexprNameExists($exprName))) 
  2620.     {
  2621.         // First, unregister the current expression, if it is
  2622.         // eligible.
  2623.         //
  2624.         EEresetExpressionName("");
  2625.     }
  2626.  
  2627.     if ($EEnodeMode == "scriptNode") 
  2628.     {
  2629.         EEresetExpressionName("");
  2630.     }
  2631.  
  2632.     scrollField -e -tx "" EEmultiText;
  2633.     radioButtonGrp -e -sl 1 EEunitsRBG;
  2634.  
  2635.     string $buffer[];
  2636.     tokenize($objAttrName, ".", $buffer);
  2637.  
  2638.     if ($EEobjIsParticle)
  2639.     {
  2640.         EEsetCreateMode("Creating Particle Expression");
  2641.  
  2642.         if ($EEcurrentEditor != 1 && $EEdoLaunchTextEd)
  2643.         {
  2644.             EElaunchParticleEditor("", $buffer[0]);
  2645.             scrollField -e -enable false EEmultiText;
  2646.         }
  2647.         textFieldGrp -e -tx "" -enable false EEdefNameT;
  2648.  
  2649.         // For a particle , the expression name must be the name of the
  2650.         // particle, so put it in the expression name textfield now.
  2651.         //
  2652.         EEresetExpressionName($buffer[0]);
  2653.         // textField -e -tx $buffer[0] EEexprNameT;
  2654.     }
  2655.     else
  2656.     {
  2657.         if ($EEnodeMode == "scriptNode")
  2658.         {
  2659.             textFieldGrp -e -tx "" -enable false EEdefNameT;
  2660.             EEsetCreateMode("Creating Script Node");
  2661.         } 
  2662.         else 
  2663.         {
  2664.             EEsetCreateMode("Creating Expression");
  2665.  
  2666.             // Set default to current obj
  2667.             //
  2668.             textFieldGrp -e -tx $buffer[0] EEdefNameT;
  2669.             checkBox -e -v true EEanimCBox;
  2670.         }
  2671.  
  2672.         if ($EEcurrentEditor != 1 && $EEdoLaunchTextEd)
  2673.         {
  2674.             EElaunchEditor($objAttrName, "", "");
  2675.             scrollField -e -enable false EEmultiText;
  2676.         }
  2677.         else
  2678.         {
  2679.             scrollField -e -enable true EEmultiText;
  2680.         }
  2681.     }
  2682.     if ($EEnodeMode == "scriptNode") 
  2683.     {
  2684.         textFieldGrp -e -tx "" EEselScriptNodeNameT;
  2685.     } 
  2686.     else 
  2687.     {
  2688.         textFieldGrp -e -tx $objAttrName EEselNameT;
  2689.     }
  2690.  
  2691.     if (!$EEdoLaunchTextEd)
  2692.     {
  2693.         $EEexpressionInEditor = -1;
  2694.         $EEpExpressionInEditor = -1;
  2695.     }
  2696.  
  2697.     $EEdoLaunchTextEd = 0;
  2698.     $EEcurrExpressionName = "";
  2699.     $EEorigExpressionName = "";
  2700.  
  2701.  
  2702. }    // EEdisplayNoExpression
  2703.  
  2704.  
  2705. //  ================ EEregisterExpressions ================
  2706. //
  2707. //  SYNOPSIS
  2708. //      Register all expressions in the scene to receive
  2709. //      expression changed messages.
  2710. //
  2711. //
  2712. global proc EEregisterExpressions()
  2713. {
  2714.     int $i;
  2715.  
  2716.     string $expressions[] = `ls -type expression`;
  2717.     for ($i = 0; $i < size($expressions); $i++)
  2718.     {
  2719.          expressionEditorListen -le $expressions[$i];
  2720.     }
  2721.     clear($expressions);
  2722.  
  2723.     if (`isTrue "DynamicsUIExists"`)
  2724.     {
  2725.         $expressions = `ls -type particle`;    
  2726.         for ($i = 0; $i < size($expressions); $i++)
  2727.         {
  2728.              expressionEditorListen -le $expressions[$i];
  2729.         }
  2730.     }
  2731.     clear($expressions);
  2732. }
  2733.  
  2734.  
  2735. // ******************************************************************
  2736. //
  2737. //                EXPRESSION EDITOR CORE PROCEDURES
  2738. //
  2739. // ******************************************************************
  2740.  
  2741. //  ================ EEupdateWindow ================
  2742. //
  2743. //  SYNOPSIS
  2744. //      Update the Expression Editor -- called when the Editor is
  2745. //      created or shown.  The expression to be put in the
  2746. //        window is that connected to nodeName.attrName 
  2747. //
  2748. //
  2749. global proc EEupdateWindow(string $nodeName, string $attrName)
  2750. {
  2751.     global string $EEcurrNodeFilter;
  2752.     global string $EEnodeMode;
  2753.  
  2754.     string $buffer[];
  2755.  
  2756.     // If an object name has been sent in, set the editor
  2757.     // to object mode and selected mode.
  2758.     //
  2759.     if (size($nodeName) > 0)
  2760.     {
  2761.         if (EEisScriptNode($nodeName))
  2762.         {
  2763.             $EEnodeMode = "scriptNode";
  2764.         } 
  2765.         else 
  2766.         {
  2767.             $EEnodeMode = "object";
  2768.             $EEcurrNodeFilter = "allSelected";
  2769.             menuItem -e -rb true EEallSelectedMenuItem;
  2770.         }
  2771.     }
  2772.  
  2773.     if ($EEnodeMode == "scriptNode") 
  2774.     {
  2775.         EEswitchSelectLayout("scriptNode");
  2776.     }
  2777.  
  2778.     if ($EEnodeMode == "object") {
  2779.          button -e -enable false EEnewExpButton;
  2780.     } else {
  2781.          button -e -enable true EEnewExpButton;
  2782.     }
  2783.  
  2784.     // Rebuild the object list. 
  2785.     // 
  2786.     EErebuildNodeList($EEnodeMode);
  2787.  
  2788.     // If an object name was sent in, load it.
  2789.     //
  2790.     if (size($nodeName) > 0)
  2791.     {
  2792.         // If it is not in the list, add it and make it the
  2793.         // selected one; and get its attribute list.
  2794.         //
  2795.         if (EEnodeIsInList($nodeName) == -1)
  2796.         {
  2797.             EEaddNodeToList($nodeName);
  2798.  
  2799.             EEnewSelectedNode($nodeName);
  2800.  
  2801.             if ($EEnodeMode != "scriptNode")
  2802.             {
  2803.                 // Load nodeName's attribute list.
  2804.                 //
  2805.                 if (size($attrName) > 0) 
  2806.                 {
  2807.                     int $attrListIndex;
  2808.                     if (($attrListIndex = EEattrIsInList($attrName)) == -1)
  2809.                     {
  2810.                         // If the attribute name as been sent in, put it in the list
  2811.                         // and select it even if it is not an attribute we don't usually
  2812.                         // put in the list, e.g. it is not keyable.
  2813.                         //
  2814.                         textScrollList -e -a $attrName EEattrList;
  2815.                         $attrListIndex = `textScrollList -q -ni EEattrList`;
  2816.                     }
  2817.                     EEnewSelectedAttr($attrListIndex);
  2818.                 }
  2819.             }
  2820.         }
  2821.         else
  2822.         {
  2823.             // If the node is in the list, load it and the specified
  2824.             // attribute, if there is one.
  2825.             // 
  2826.             // But first, if an attribute name is sent in and is not in the
  2827.             // attr list, add it.
  2828.             // 
  2829.             EEnewSelectedNode($nodeName);
  2830.  
  2831.             if (size($attrName) > 0)
  2832.             {
  2833.                 int $attrListIndex;
  2834.                 if (($attrListIndex = EEattrIsInList($attrName)) == -1)
  2835.                 {
  2836.                     textScrollList -e -a $attrName EEattrList;
  2837.                     $attrListIndex = `textScrollList -q -ni EEattrList`;
  2838.                 }
  2839.  
  2840.                 EEnewSelectedAttr($attrListIndex);
  2841.             }
  2842.         }
  2843.     }
  2844.  
  2845.     EEregisterExpressions();
  2846.  
  2847. }    // EEupdateWindow
  2848.  
  2849.  
  2850. //  ================ expressionEditor ================
  2851. //
  2852. //  SYNOPSIS
  2853. //      Create and show an expression editor text dialog.
  2854. //
  2855. //
  2856. global proc expressionEditor(string $particleMode, 
  2857.                                 string $nodeName, string $attrName)
  2858. {
  2859.     global int $EEcurrentEditor;
  2860.     global int $EEisRuntime;
  2861.     global int $EEfilesLoaded;
  2862.  
  2863.     if (!$EEfilesLoaded)
  2864.     {
  2865.         source expressions.mel;
  2866.         source dynExpressions.mel;
  2867.         source expressionEdCallbacks.mel;
  2868.         source expressionEdTextEditor.mel;
  2869.         source scriptNodes.mel;
  2870.  
  2871.         $EEfilesLoaded = 1;
  2872.     }
  2873.     
  2874.     // Check that nodeName exists and attrName is valid.
  2875.     //
  2876.     if (size($nodeName) > 0)
  2877.     {
  2878.         if (!`objExists $nodeName`)
  2879.         {
  2880.             warning("ExpressionEditor: " + $nodeName + " does not exist.");
  2881.             $nodeName = "";
  2882.             $attrName = "";
  2883.         }
  2884.     }
  2885.     else
  2886.     {
  2887.         // If there is no nodeName, make sure attrName is also blank.
  2888.         //
  2889.         $attrName = "";
  2890.     }
  2891.  
  2892.     if (size($nodeName) > 0 && size($attrName) > 0)
  2893.     {
  2894.         // If attrName is not an attribute for nodeName, don't use it.
  2895.         //
  2896.         if (size(`ls ($nodeName + "." + $attrName)`) == 0)
  2897.         {
  2898.             warning("ExpressionEditor: " + $attrName + " does not exist for object " + $nodeName + ".");
  2899.             $attrName = "";
  2900.         }
  2901.         else
  2902.         {
  2903.             if (size($particleMode) == 0)
  2904.             {
  2905.                 // If the attribute cannot be set in an expression, don't 
  2906.                 // put it in the editor.
  2907.                 //
  2908.                 string $attrs[] = 
  2909.                     `listAttr -scalar -multi -string $attrName $nodeName`;
  2910.                 if (size($attrs) == 0)
  2911.                 {
  2912.                     warning("ExpressionEditor: " + $attrName + " can not be modified by an expression.");
  2913.                     $attrName = "";
  2914.                 }
  2915.             }
  2916.         }
  2917.     }
  2918.     string  $EEWin = "expressionEditorWin";
  2919.     int $callListen = 0;
  2920.  
  2921.     if ($particleMode == "runtime")
  2922.         $EEisRuntime = 1;
  2923.     else if ($particleMode == "creation")
  2924.         $EEisRuntime = 0;
  2925.  
  2926.     if ( `optionVar -exists EEexprEdTextEditor` )
  2927.         $EEcurrentEditor = `optionVar -q EEexprEdTextEditor`;
  2928.  
  2929.     if (size($nodeName) > 0 && 
  2930.         size($attrName) > 0 && 
  2931.         $EEcurrentEditor != 1)
  2932.     {
  2933.         if (EEisParticle($nodeName))
  2934.         {
  2935.             // Find out if the attribute is connected to a TdnExpression.
  2936.             // If it is, treat it like a non-particle attribute.
  2937.             //
  2938.             string $objAttr = $nodeName + "." + $attrName;
  2939.  
  2940.             if (EEisDynExpression($objAttr))
  2941.                 EEonlyLaunchParticleEditor($nodeName, $attrName);
  2942.             else
  2943.                 EEonlyLaunchEditor($nodeName, $attrName);
  2944.         }
  2945.         else if (EEisScriptNode($nodeName))
  2946.         {
  2947.             EEonlyLaunchScriptEditor($nodeName, $attrName);
  2948.         }
  2949.         else
  2950.         {
  2951.             EEonlyLaunchEditor($nodeName, $attrName);
  2952.         }
  2953.         return;
  2954.     }
  2955.  
  2956.     if (! `window -exists $EEWin`)
  2957.     {
  2958.         EEcreateWin($EEWin);
  2959.         $callListen = 1;
  2960.     }
  2961.  
  2962.     EEupdateWindow($nodeName, $attrName);
  2963.  
  2964.     if ($EEisRuntime)
  2965.         radioButtonGrp -e -sl 1 EErulesRBG;
  2966.     else
  2967.         radioButtonGrp -e -sl 2 EErulesRBG;
  2968.  
  2969.     if ($callListen)
  2970.         expressionEditorListen();
  2971.     
  2972.     // Open/display the editor.
  2973.     //
  2974.     showWindow $EEWin;
  2975.  
  2976. }    // expressionEditor
  2977.  
  2978.